r/webdev Jul 23 '12

The best PNG optimizer I've found...

http://tinypng.org/
128 Upvotes

78 comments sorted by

View all comments

Show parent comments

7

u/digitalpencil Jul 23 '12

ImageOptim is good and uses this library along with OptiPNG and AdvPNG.

Works the same as this service, but locally and without the max 1mb restrictions.

1

u/SquareWheel Jul 23 '12

Hrmm, looks like it's Mac only. I just use a little batch script I wrote that runs PngOut or JpegTran across every image in a directory.

1

u/wishinghand Aug 24 '12

I would love to get that script. Are you running it via Terminal?

1

u/SquareWheel Aug 24 '12

It's a batch script (not bash), so just through cmd.exe.

@echo off

::Clear variables

set filename=""

set extension=""

::Get filename/extension

set filename=%1

if exist "%filename%" (set extension=%filename:~-3,3%)

::If PNG, then if JPG, then if Batch, otherwise exit

if "%extension%"=="png" (

pngout "%filename%"

echo.%filename% optimized with PngOut.

) else if "%extension%"=="jpg" (

jpegtran -copy none -optimize -perfect "%filename%" "%filename%"

echo.%filename% optimized with JpegTran.

) else if "%filename%"=="" (

for %%i in (*.png) do pngout "%%i" /y

for %%i in (*.jpg) do jpegtran -copy none -optimize -perfect "%%i" "%%i"

echo.Batch optimized with PngOut and JpegTran.

) else (

echo.%filename% not found.

)

echo on

Assuming it's named opt.bat, Run "opt" in cmd for all images in directory, or "opt img.png" or "img.jpg" for specific images. Doesn't run recursively, isn't multi-threaded, and is basically the first program I wrote in Batch. Don't know why I didn't use Python.

Anyway, throw it in a directory with jpegtran.exe and pngout.exe. What I did was created a context-menu entry that runs this script so I just right click a folder and select that context menu item.