samastur / image-diet Goto Github PK
View Code? Open in Web Editor NEWA Django application for removing unnecessary bytes from images. Integrates seemlessly with Easy Thumbnails.
License: MIT License
A Django application for removing unnecessary bytes from images. Integrates seemlessly with Easy Thumbnails.
License: MIT License
It would be good if image-diet could work from collectstatic.
Not sure if this is the best place, or maybe integration with something like django-pipeline would be better ?
I learned of an interesting trick. It seems that enlarging JPEG width and height by 2 and then heavily compressing results in smaller image with about equal quality (when scaled in browser to 50%).
Need to do more tests, especially with PIL. Another thing to consider is memory consumption since thus resized images should take about 4x as much memory which may be serious problem for mobile devices with limited RAM.
Check out effectiveness of PNG tools listed at http://css-ig.net/png-tools-overview.
Check also JPEG tools used in http://css-ig.net/scriptjpg
Right now the package is registered, but not uploaded to pypi. This makes installing image-diet harder than it should be.
Just run a 'python setup.py sdist upload' or upload it through the pypi site and people can start using this useful piece of software without any hurdles.
Could be a great addition to existing tools.
Found at: http://pngquant.org/
I am really unhappy with the way I wrote image-diet. It bothers me that it supports only EasyThumbnails and filesystem storage. It bothers me that tools with their parameters are baked in so you can't add a new one or change their parameters without mucking around code. This also makes it impossible to create a test suite to find combination of tools and settings that works best in your scenario. It's a mess.
So I would like to rewrite/refactor it with following goals:
It would be nice if current version's settings would still work, but that is not a requirement.
Django has supported custom storage backends for a while now and new version of image-diet would come with two components. A storage mixin doing the squeezing of images as they flow to storage and a filesystem backend that uses it so it is at the same time an example of mixin use and easier default choice. This mixin will still require access to filesystem (can be temporary) since at least some optimizing tools can only work with files.
Process pipeline should know as little as possible about images or processing. It's main purpose would be to identify the type of image (file), select the right pipeline definition and manage processing pipeline (run tools in order specified in configuration file and provide seamless handling of stdin/file inputs.
Everything else should be stored in configuration file (default one which could be overridden by user's). Configuration file would store info about tools themselves: location, configuration options and type (does it read data from stdin or from file). It would also define pipelines for each image type (which tools are used for processing and their order). Not sure which format would be better: python (dicts&co) or something like YAML.
Adding a new tool or even a new image type could then be done completely with configuration. All it would need is to add tool definition, new type section with its pipeline.
If it was done well, then it would not even care if files in question are images and could in principle process other files too (but that is not its goal).
Thoughts, suggestions and critic are very welcome.
Just to let you know:
I installed all requirements through installing imageoptim (http://imageoptim.com) and then symlinking from /usr/bin/ to all the required packages:
sudo ln -s /Applications/ImageOptim.app/Contents/MacOS/advpng
sudo ln -s /Applications/ImageOptim.app/Contents/MacOS/gifsicle
sudo ln -s /Applications/ImageOptim.app/Contents/MacOS/jpegoptim
sudo ln -s /Applications/ImageOptim.app/Contents/MacOS/jpegtran
sudo ln -s /Applications/ImageOptim.app/Contents/MacOS/optipng
sudo ln -s /Applications/ImageOptim.app/Contents/MacOS/pngcrush
Seems to have worked. Might be something to add to the readme?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.