Weird Looking: using pngcrush in windows

using pngcrush in windows

August 31, 2006 5:00am (3 years, 6 months and 6 days ago)
tags: website png
pngcrushery
I pngcrushed this image.
Disclaimer: I don’t know what I’m doing.

As we all know, png images are the best thing that’s ever happened.  Unfortunately, lots of image editors wantonly save gama and other chunks in them without asking.  This can cause pngs to be rendered a different color than elements in the web page they were supposed to match.  So I fixed XP to have an option in the context menu for .png files to run them through pngcrush.  It’s nothing fancy, but it’s improved my workflow.  And this is how I did it!

First, you’ll want to go get pngcrush.  If you manage to navigate you way through sourceforge’s download region, you’ll wind up with a win32 executable and some other unimportant junk.  You should put that executable somewhere safe – Mine is called C:\pngcrush\pngcrush.exe.

Next, create a couple of files:

C:\pngcrush\pngcrush.bat:

copy %1 %1.bak
C:\pngcrush\pngcrush.exe -rem gAMA -rem cHRM -rem iCCP -rem sRGB -brute -l 9 %1 %TMP%\pngcrush-tmp.png
copy %TMP%\pngcrush-tmp.png %1
del %TMP%\pngcrush-tmp.png



pngcrush.reg:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\pngfile\shell\Pngcrush]
@="&Pngcrush"

[HKEY_CLASSES_ROOT\pngfile\shell\Pngcrush\command]
@="\"C:\\pngcrush\\pngcrush.bat\" \"%1\""



Obviously you’ll have to adjust the paths if you’re a sissy and don’t save everything in a directory off C:\ the way I do.  And if you don’t like my pngcrush options, you don’t know what you’re doing.  Anyway, run that .reg file.  If successful, you should now have a “Pngcrush” option when you right-click on .png files!

Comments

Sep 7, 2006 10:53pm
I would like to subscribe to your newsletter.  Thanks, I did this.  Very helpful.  Now if only I weren’t trying to design an ASP site on a XP Home laptop without IIS, I’d be a much happier camper.  I feel like I’m writing Fortran again.  “Oh, that had a typo, too…”
Sep 8, 2006 6:18am
I tried to hax0r my computer to do that one too.

Let me click it, you meany!

IIS on Home attempt
Sep 8, 2006 10:23am
Windows 98 could run PWS.  Windows XP Media Center comes with IIS.  But Windows XP Home is stuck with nothing.

That makes perfect sense.

Too bad you’re not working on ASP.NET right now, as there are many options for running them on Windows XP Home.

I’m not unconvinced that IIS cannot be installed on XP Home.  It seems like some people have had success.
Sep 8, 2006 10:24am
Ignore my triple negative above, and change it to “I am not convinced that IIS cannot be installed…”

Now that Firefox has a spell checker I find myself wanting a grammar checker.
Jun 15, 2007 7:42am
I found your solution smart, but it didn’t work for me. One will need to fix png-files when having installed Photoshop, and in that case Photoshop takes control over png-files.

Example: You have Photoshop 9 (CS2) installed. In that case you’ll have to add the “pngcrush”-section to the HKEY_CLASSES_ROOT\Photoshop.PNGFile.9 key in your registry.

pncrush.reg would then look like this:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Photoshop.PNGFile.9\shell\Pngcrush]
@="&Pngcrush"

[HKEY_CLASSES_ROOT\Photoshop.PNGFile.9\shell\Pngcrush\command]
@="\"C:\\pngcrush\\pngcrush.bat\" \"%1\""

Please add information about other Photoshop versions here, the author of pngcrush liks to this page.
Jul 26, 2007 6:04am
I made a similar registry hack some time ago. If I recall correctly, I added a custom action using Windows own interface (in explorer, Tools-> Folder options-> File types) and then looked for it in the registry. Windows interface doesn’t allow you to modify PNG options so I created a random extension for testing purposes (e.g., .foobardotcom), which also helped when findint it with regedit. Conclusion:

HKEY_CLASSES_ROOT\SystemFileAssociations\.png\shell

Leave a comment


Accepts BBCode with a few enhancements.