In this update we’ve added a new --exclude flag to the hypernode-image-optimizer. This option allows you to exclude specific subdirectories from the automated Magento image optimization. This can be handy in case you have already pre-optimized some images before deployment and you don’t want the optimizer to look at them again.

app@83f01a-vdloo-magweb-cmbl:~$ hypernode-image-optimizer --help
usage: hypernode-image-optimizer [-h] [-w] [-q QUALITY] [-s SIZE] [-n] [-x]
                                 [--exclude EXCLUDE [EXCLUDE ...]]
                                 path

Automatically optimize PNG and JPG files under a directory tree. Make sure you
have a backup of your images, and visually inspect the results before applying
for real!

positional arguments:
  path                  File or dir to (recursively) process

optional arguments:
...
  --exclude EXCLUDE [EXCLUDE ...]
                        Specify one or more paths in which the files will be
                        ignored. Space delimited. (default: None)

The hypernode-image-optimizer can be used to save disk space and speed up your shop by shrinking images without quality loss (depending on the compression level). It is very easy to use and many people run it in a periodic cron so it optimizes images in a shop every night.

$ hypernode-image-optimizer ~/public/media
[46%] /data/web/public/media/custom_options/quote/h/o/46f68f14df54b639546a583a942cd7c2.png (255 KB smaller)
[50%] /data/web/public/media/custom_options/quote/h/o/8a45641021fb82d172b9712f6631c49a.png (405 KB smaller)
[30%] /data/web/public/media/custom_options/quote/p/l/a74e500c8e08c48e54ea65d8422bc68e.png (114 KB smaller)
[77%] /data/web/public/media/custom_options/quote/L/i/8969288f4245120e7c3870287cce0ff3.jpg (426 KB smaller)
[ 0%] /data/web/public/media/custom_options/quote/T/a/6bfddcd09ff981b24fc96e442700f2df.png (0 KB smaller)
[... long list of files ...]
Optimization profit over all files: 226 MB (30%)

To use the hypernode-image-optimizer and exclude one or more directories, specify --exclude with one or more paths. For example:

app@83f01a-vdloo-magweb-cmbl:~$ hypernode-image-optimizer /data/web/public | wc -l
431
app@83f01a-vdloo-magweb-cmbl:~$ hypernode-image-optimizer /data/web/public --exclude /data/web/public/static/frontend /data/web/public/static/adminhtml/Magento | wc -l
12
# In this example images from the following directories were ignored:
# /data/web/public/static/frontend
# /data/web/public/static/adminhtml/Magento

Thanks to Tjerk Ameel from Indie Group for suggesting to add an option to exclude specific directories.