onsdag 14 mars 2012

ImageMagic to rescue

If you are a Android developer, and working with an app that uses png’s (or other images) you may recognize this:

OutOfMemory Exception

It is no game. My app (Zappa, a remote control for a settop-box) uses a lot of images - the channel icons. There are hundreds. And they change every now and then. And sometimes one (or two) of a batch of new png’s is too large; 512x512 instead of 88x88. You can’t tell from the file size in the file system.

It is here ImageMagic comes to rescue http://www.imagemagick.org. Really easy to install and use (I use a Mac and MacPort):

$ port install ImageMagick
$ … (omitted a lot of stuff)


then, in the res/drawable folder

$ identify ch_*.png
$ ch_10.png[1] PNG 88x88 88x88+0+0 8-bit DirectClass 7.65KB 0.000u 0:00.000
$ ch_100.png[2] PNG 512x512 512x512+0+0 8-bit DirectClass 8.62KB 0.000u 0:00.000
$ ...
$ identify ch_*.png | grep 512x512 | awk 'FS="[" {print $1}

Voila!  The guilty png's are listed.

Inga kommentarer:

Skicka en kommentar