Current time: 01-17-2021, 04:51 AM Hello There, Guest! (LoginRegister)

Post Reply 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need to losslessly optimize large pngs. (5MB and bigger)
01-16-2014, 08:57 AM (This post was last modified: 01-16-2014 09:08 AM by robzilla.)
Post: #8
RE: Need to losslessly optimize large pngs. (5MB and bigger)
An example with OptiPNG:

If you want to use OptiPNG, you'll have to build it from source first, since it's not in any of the main repositories.

yum -y install gcc
cd /tmp
tar -xzvf optipng-0.7.4.tar.gz
cd optipng-0.7.4
make install

If you'd rather use PNGout, just issue:

yum -y install pngout

That's assuming you have the EPEL repository. If not:

rpm -Uvh
yum install optipng --enablerepo=epel

If you didn't have the EPEL repo, you may want to disable it again afterwards by setting "enabled=0" in /etc/yum.repos.d/epel.repo.

Anyway, assuming you've installed OptiPNG and your PNGs are in a directory like "/tmp/png":

cd /tmp/png
find . -iname "*png" -print0 | xargs -0 --max-procs=4 -n 1 optipng -dir /tmp/png-opt/ &

The first part locates all PNG files in the current directory, the xargs bit takes that input and creates a queue of files to pass on to OptiPNG, where --max-procs is the number of processes to start (i.e. cores to use). The -dir directive tells OptiPNG to save the compressed images to a /tmp/png-opt directory. You can pass other options like the optimization level, if you like. The ampersand at the end will ensure the jobs keep running even if you've closed your SSH session.

No guarantees, of course, but I've just tested it on an 8-thread VPS (CentOS 6.5) and it seems to be working rather well.

Hope that helps.
Find all posts by this user
Quote this message in a reply
Post Reply 

Messages In This Thread
RE: Need to losslessly optimize large pngs. (5MB and bigger) - robzilla - 01-16-2014 08:57 AM

Forum Jump:

User(s) browsing this thread: 1 Guest(s)