views:

164

answers:

1

Hey All,

I have a group of png files in my bundle; but I also want smaller versions of them to be used at my app as well. Right now I am just resizing them all manually and putting them in the bundle as well: so i might have Graphic_1.png and Graphic_1-thumbnail.png.

Instead, is there anyway to do something like: at build time, take all my png assets and create 1/4 scale versions of them, and save them into the bundle as well, with the -thumbnail in the filename as above? Thanks!

+1  A: 

You can create a bash script for a custom build phase of your project. (Haven't tried to see if automator would work) This would require you to have something like Image Magick installed.

Right click on your target and click "Add > New Build Phase > New Run Script Build Phase"

Set the shell to /bin/bash. For the script:

FILES="*.png"
for f in "$FILES"
do
`convert $f -resize 25% thumb-$f`
done

Any other command line image processing tool would work in place of Image Magick. You likely need to adjust the FILES variable to the real location of your images.

Mike
Interesting; thanks! So I guess I'd need to make a copy of the original images first as part of the script? I'd also need this to work for PVRTC type images too, I'll have to see if Image Magick does that.