Monday, January 25, 2010

Useful PNG commands

Useful command for handling PNG files.

Prerequisites: ImageMagick, Pngcrush

Resizing

Resize to a given maximum size

for i in *png ; do convert $i -geometry 16x16 x/$i; done

Resize exactly to given size, adding transparent borders

for f in $(for i in x/* ; do file $i | grep -v '16 x 16' | cut -d: -f1; done) ; 
  do convert $f -type TrueColorMatte -compose Src -gravity center -extent 16x16 y/$f ; 
done

Optimizing

Trying different PNG compression settings, removing extra PNG contents (such as comments)

for i in y/*png ; do pngcrush  -rem alla -reduce -brute "$i" z/"$i"; done

No comments:

Post a Comment

Home

Followers