Contains a script for automatically optimizing images in a CMS like Typo3.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Sebastian M. (Stadt Treuchtlingen) caa8f92f0f
Update ''
1 month ago
LICENSE Initial commit 1 month ago Update '' 1 month ago Fixed a typo 1 month ago


This script is licensed under the AGPL-3.0 License.

By default it applies lossless image optimization to all png and jpeg images (currently by file extension to improve performance) to all image files it finds inside a given directory.


  • optipng
  • jpegoptim

Both can be found under this name in most package repositories.


One may ask why an external script and not an addon for the CMS?

The answer is: Every addon adds complexity to your CMS and makes it more difficult to maintain, this script runs independent of your CMS and save you some headaces this way.

Using it

Basic usage: --dir /path/to/image/directory/

Warning: Make sure to run it as the user that owns the images, for a CMS on Debian this is likely the www-data user, otherwise you may have problems with your CMS no longer being able to modify or access the optimized files.

To avoid problems in such a scenario use it like: sudo -u www-data --dir /path/to/image/directory/


Because a CMS with multiple people working on it has to deal with unoptimized images on a regular basis it makes sense to run this script as a cronjob.

sudo -u www-data crontab -e

And add a line that looks similar to this one:

# For more information see the manual pages of crontab(5) and cron(8)
# m h  dom mon dow   command
42 8 * * 5 --dir /path/to/image/directory/

This example will run it every Friday morning on 8:42.

To make your life easier: Here is a link to the Debian crontab(5) manpage.