Reputation: 563
Is it possible to set up an observer whenever a product image is added, run a shell script to optimize the image or something like that? Maybe it can extend further beyond just product images. Detect new image on the server and run jpegoptim or pngoptim only on the newly added images?
Upvotes: 1
Views: 1281
Reputation: 4360
Assuming you are using a Linux based OS and you have enough privileges you could have a look at inotify or fanotify.
I know there exist inotify bindings for Python, Ruby, Haskell and others. There's also a package providing command line tools. And there also exists a inotify based cron daemon.
Also related: How do I program for Linux's new fanotify
file system monitoring feature?
Upvotes: 0
Reputation: 17656
In magento, because catalog images are created dynamically from the image uploaded in admin on first page view (catalog list, product detail, etc) using
$this->helper('catalog/image')->init($_product)->resize(163, 100);
it is NOT possible to use any default product observer (like Magento Add New product event observer) to optimizing the images, plus you can always delete all product image using admin (System -> Cache Management).
One possible solution (assuming that you have right access on your server)
Upvotes: 1