Public Service Announcement about Image-/Graphicsmagick ;)
Imagemagick/Graphicsmagick have a batch image manipulation tool called mogrify. For example "mogrify -format jpeg -geometry 512 -quality 75 -path other/dir/ *.png". There usually is no need for any awkward loops that use convert once per image.
Posting this here since the linked site requires Javascript for comments.
Thanks for the tip. I read the docs for mogrify just now, but it says it overwrites images and I don't see any option to change that or add a different output path. The need here is to take a source image from a folder like drawable-hdpi, and produce a new, converted image in a folder like drawable-ldpi. I guess maybe you could copy everything first, then modify it? Although that seems more clumsy than just running the find command already being used. Thanks for the help!
This brings up an interesting need: ability to easily and affordable test/simulate across the thousands of android or mobile devices. An emulator with CPU/gpu specs for each model..
You don't really need that many devices, and the cheap devices are cheap. For this kind of issue you can just use older devices since they automatically have lower specs. For example I use a G1 from 2008.
I wonder how easy it would be to get Android doing this automatically. It would certainly improve performance if images could be scaled once on installation of the APK instead of every time they are displayed.
Another advantage is that technically the Android Market will let you upload multiple APKs for a single market entry now as long as they are only compatible with different devices. So it is possible to post a different APK for each density class using compatible-screens targeting...
I wonder what the dimensions of the bitmap that caused the OutOfMemoryError were? Usually ActionBar icons are small, so it seems weird that such a small image would cause an OOME.
15 comments
[ 88.9 ms ] story [ 250 ms ] threadImagemagick/Graphicsmagick have a batch image manipulation tool called mogrify. For example "mogrify -format jpeg -geometry 512 -quality 75 -path other/dir/ *.png". There usually is no need for any awkward loops that use convert once per image.
Posting this here since the linked site requires Javascript for comments.
a) defeat the point of signing
b) require a new version of Android (which these low-end phones aren't likely to get)
It'd be far easier and more effective to tweak the build tools to crunch the images before packing up the APK in the first place.