Magento Image Optimization

Topics focus on Web Developments, Programming, Database, Digital Marketing Tutorials, Code Snippets, SEO, Social Media Marketing and Inspirational articles.

Magento Image Optimization

Magento Image Optimization

Magento Image Optimization

First you need a ssh access to the server.

Second – install jpegtran / optipng / gifsicle utilities – refer to your platform packages for the right one.

Idea is simple – iterate over all images / backup / optimize / swap backups.

Here it is:

1
2
3
4
5
6
7
8
9
10
#!/bin/bash
 
find ./js ./skin ./media -iname '*.gif' -exec sh -c \
    'gifsicle -b -O3 -o "{}.out" "{}"; mv "{}.out" "{}"' \;
 
find ./js ./skin ./media -iname '*.png' -exec \
    optipng -o5 -keep -preserve '{}' \;
 
find ./js ./skin ./media -type f -iname '*jpg' -exec sh -c \
 'jpegtran -outfile "{}.out" -optimize "{}"; mv "{}.out" "{}"' \;

Please suggest a better way to optimize images in bulk in comments if you know one.

Although gtmetrix still complains about some of the images not optimized it is the closest i can get so far.

Add comment


 

Pin It on Pinterest

Share This