Compressing PNG file for the web

When using images on the web, it’s impotent to use the smallest file you can for your needs. This doesn’t mean you should use a image that is smaller then the size you wish to display it at, but to optimize it for the web and not send more then is needed.

With this goal, here is a quick way of optimizing all PNG files in a set of directories using optipng.

for a in `find /var/www/wordpress/ |egrep '*.png$'`
do
    /usr/bin/optipng $a
done

Don’t worry if you already have some images that are already optimized, optipng will just skip them.

Advertisements

1 thought on “Compressing PNG file for the web

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s