GithubHelp home page GithubHelp logo

samastur / image-diet Goto Github PK

View Code? Open in Web Editor NEW
51.0 51.0 6.0 222 KB

A Django application for removing unnecessary bytes from images. Integrates seemlessly with Easy Thumbnails.

License: MIT License

Python 100.00%

image-diet's People

Contributors

remik avatar samastur avatar yakky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

image-diet's Issues

Compress images during collectstatic ?

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 ?

Reduce JPEG size by making them twice the size and heavily compressed

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.

Upload to PyPi

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.

Refactor/rewrite image-diet

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:

  • still easy to get going (dead simple support for filesystem storage)
  • can also support other storage backends and thumbnails apps with minimum of fuss
  • adding new tools should be easy; also changing their parameters
  • changing configuration should require no programming knowledge

It would be nice if current version's settings would still work, but that is not a requirement.

Ideas on how to do this

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.

Installing requirements via imageoptim on osx

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.