Shrink PNG file size from the console

How to decrease png file size dramatically

ape in a dress dancingPngquant bills itself as a command-line utility and a library for lossy compression of PNG images. Over on Sourceforge, optipng claims to be a PNG optimizer that recompresses image files to a smaller size, without losing any information. Combining optipng’s optimization with pngquant’s compression can drastically decrease png file sizes.

WordPress, not happy with just being a blogging software, has grown into an extremely popular do-it-all framework. Let’s use some of the basic icons and logo images provided with every installation to showoff the power of optipng and pngquant. The wp-admin/images directory contains a bunch of images, utility stuff.

Let’s look at two files, the largest in the directory and another somewhere in the middle that already seems pretty small to begin with.

Major Reduction

icons32-vs-2x.png is 37,994 bytes. Squash it with pngquant’s lossy image compression, then re-optimize it with optipng and it’s down to 21,803 bytes. That’s almost half the original size. Yet to the naked eye, the data loss is, for most intents and purposes, unnoticeable.

Minor Reduction Army

Let’s examine the w-logo-blue.png for instance. This is used as the stylized ‘W’ icon that shows up on the login page.
Provided by WordPress, it’s a whopping 3,112 bytes. After lossy image compression and re-optimization, it’s only 3,093 bytes. A waste of time for a minor reduction of 1%, but not when you repeat this process for hundreds of images. The real power is obvious when you shrink a few larger files but every bit counts, literally. Multiply that squad of itty-bitty images by the number of times your pages are served and now we’re getting somewhere.

So let’s crush a whole directory at once.


Run pngquant on all the files ending in ‘png’ and do it in place instead of creating new files by specifying the extension with ‘-ext’.

for x in `ls *.png`; do pngquant -f -ext .png $x; done


Squeeze out a little more by optimizing the new files with optipng.

for x in `ls *.png`; do optipng -o7 $x; done

You can use the most exhaustive search “not generally recommended” by optipng’s help page, probably because it takes so long and doesn’t make much difference. May as well if you don’t care how long it takes.

for x in `ls *.png`; do optipng -zc1-9 -zm1-9 -zs0-3 -f0-5 $x; done

Download and build proxytunnel in Fedora

This program connects stdin and stdout to a server somewhere on the network, through a standard HTTPS proxy. We mostly use it to tunnel SSH sessions through HTTP(S) proxies, allowing us to do many things that wouldn’t be possible without it.

* Create tunnels using HTTP and HTTPS proxies (That understand the HTTP CONNECT command).
* Work as a back-end driver for an OpenSSH client, and create SSH connections through HTTP(S) proxies.
* Work as a stand-alone application, listening on a port for connections, and then tunneling these connections to a specified destination.

This was originally posted on rootninja back in December 2009 and dug up from the Internet graveyard that is the wayback machine. Versions of Fedora and this app have changed significantly. Use this howto as-is at your own risk. As of Fedora 21 (at least), you’re better off using yum to download the prebuilt and configured binary version instead of building it (as far as just getting it to work goes anyway!) But hey, maybe you’re still using Fedora 12 for one reason or another. No judgement.

Get it

$ svn co

    A trunk
    A trunk/website
    A tags/v1-6-0-rc1/proxytunnel/Makefile.cygwin
    A tags/v1-6-0-rc1/proxytunnel/Makefile
    Checked out revision 248. 

Build it

Getting it built seems to be pretty straight forward stuff…

$ make

    make -C docs
    make[1]: Entering directory /home/svn/proxytunnel/trunk/proxytunnel/docs'
    asciidoc -b docbook -d manpage proxytunnel.1.txt
    make[1]: asciidoc: Command not found
    make[1]: *** [proxytunnel.1.xml] Error 127
    make[1]: Leaving directory /home/svn/proxytunnel/trunk/proxytunnel/docs’
    make: *** [docs] Error 2 

$ yum install asciidoc

    Running Transaction
    Installing : asciidoc-8.4.5-4.fc12.noarch 1/1
    asciidoc.noarch 0:8.4.5-4.fc12

$ make

    make -C docs
    make[1]: Entering directory /home/svn/proxytunnel/trunk/proxytunnel/docs'
    asciidoc -b docbook -d manpage proxytunnel.1.txt
    xmlto man proxytunnel.1.xml
    make[1]: xmlto: Command not found
    make[1]: *** [proxytunnel.1] Error 127
    rm proxytunnel.1.xml
    make[1]: Leaving directory /home/svn/proxytunnel/trunk/proxytunnel/docs’
    make: *** [docs] Error 2

$ yum install xmlto

    Running Transaction
    Installing : xmlto-0.0.23-2.fc12.x86_64 1/1
    xmlto.x86_64 0:0.0.23-2.fc12

$ make

    Note: Writing proxytunnel.1
    asciidoc -d manpage proxytunnel.1.txt
    asciidoc proxytunnel-paper.txt
    rm proxytunnel.1.xml
    make[1]: Leaving directory `/home/svn/proxytunnel/trunk/proxytunnel/docs’

$ ./proxytunnel –help

    proxytunnel 1.9.0 (rev 248) Copyright 2001-2008 Proxytunnel Project
    Usage: proxytunnel [OPTIONS]…
    Build generic tunnels trough HTTPS proxies using HTTP authentication

    Standard options:
    -i, –inetd Run from inetd (default: off)
    -a, –standalone=INT Run as standalone daemon on specified port
    -p, –proxy=STRING Local proxy host:port combination
    -r, –remproxy=STRING Remote proxy host:port combination (using 2 proxies)
    -d, –dest=STRING Destination host:port combination
    -e, –encrypt SSL encrypt data between local proxy and destination
    -E, –encrypt-proxy SSL encrypt data between client and local proxy
    -X, –encrypt-remproxy SSL encrypt data between local and remote proxy

    Additional options for specific features:
    -F, –passfile=STRING File with credentials for proxy authentication
    -P, –proxyauth=STRING Proxy auth credentials user:pass combination
    -R, –remproxyauth=STRING Remote proxy auth credentials user:pass combination
    -N, –ntlm Use NTLM based authentication
    -t, –domain=STRING NTLM domain (default: autodetect)
    -H, –header=STRING Add additional HTTP headers to send to proxy
    -x, –proctitle=STRING Use a different process title

    Miscellaneous options:
    -v, –verbose Turn on verbosity
    -q, –quiet Suppress messages
    -h, –help Print help and exit
    -V, –version Print version and exit

And there you have it, enjoy.

Linux Mint is the best Operating System available today

This distribution of Linux is the best setup available today for the desktop.

Since Mint is based on Ubuntu or Debian depending on your choice, the installation and setup is simple and easy. You can even install it while running in live mode or from inside Windows using Ubuntu’s wubi installer.

Where Ubuntu and Fedora have recently shunned almost everyone with their new half-developed unity desktop, this distro shines through. I really enjoy the LXDE environment over Gnome, but the choice is yours to pick and choose what you like to use.

Choice is one of many reasons why I really like this distribution over the other popular flavours right now.

I share the same dissatisfaction for Unity and Gnome 3 with most of the community. While this is the main reason for jumping ship and crashing the party, there are some really simple things I like, like Dropbox.

You dont have to go and download it to start using it, its right there in the start menu. But not installed yet so its not taking up space. This is one of the many reasons why maintaining compatibility with Ubuntu is a good thing. Click on it to start it, and tells you it needs to download. One more click and you’re off.

Once its done, just log in with your account or make a new one, and thats it. I wish all services worked that well.

I think Microsoft is heading in the right direction with swipe gestures for unlocking the desktop, but I hope they take a hint from the recent Gnome debacle and make it configurable. I want the option to jump right into desktop mode without having to bother with metro at all if that’s what I like. For desktop users, forcing you to use metro will be a deal breaker. Remember how bad ME and Vista were?

The sad part is Microsoft doesn’t have a history of giving you much choice in anything and their track record for anything mobile is horrible.

But enough about Windows, especially since is not even available yet. Mint is the choice for desktops today. From the simple, straightforward installer to the fact that everything just works the way it should, it picks up where Ubuntu fails.

Install VirtualBox Guest Additions on Linux Mint

I used to like Ubuntu, before they simultaneously dumbed down the user interface and complicated the administration. The current direction of Ubuntu and Fedora is just plain bad, but that’s a story for another day. Let’s look at our wonderful Ubuntu replacement, Linux Mint.
green lxde logo
When installing Mint, you get a choice of desktop environments. LXDE is fast, lightweight, and uses GTK, which I’m already very familiar with. It’s not bloated like Gnome. It’s everything Gnome wishes it was. If you use Gnome, stop right now and do yourself a favor, install LXDE. Even if you’re hooked on another distribution, there are usually alternative versions available such as Fedora’s LXDE spin. Or just go through package installation of .deb or .rpm files using your favorite package manager. You’ll never look back.

The only problem i’ve had with LXDE and Mint is that running as a guest in VirtualBox, the guest additions will not install properly. I tried mounting the additions from the host and installing them, no dice. I tried installing from the software repositories using the aptitude update manager, no dice.

After attempting an installation from either method, open a terminal and go to the source directory that you just installed. Run make and make install. Voila! Now restart the guest and enjoy the seamless mouse and keyboard integration.

So it didn’t work out of the box for me, but a quick recompile did the trick. No moving around files or manipulating configurations are necessary, just recompile for the running kernel and you’re in business.