Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is PngCrush in iOS?

i know that Pngcrush is an image optimisation technique in iOS , but my doubt is does X-code will perform this internally during each build or before deploying our app to iTunes store we need to do this image optimization?

like image 796
Graham Bell Avatar asked Dec 28 '22 00:12

Graham Bell


2 Answers

Xcode does the conversion during build. The final app will have modified pngs, you don't have to do anything manually.

like image 193
wrock Avatar answered Dec 30 '22 09:12

wrock


The PNG crushing is done using the pngcrush tool which you can access manually with this command:

xcrun -sdk iphoneos pngcrush -iphone ...

Xcode will do this automatically for any files added to your target with the "PNG" file type:

enter image description here

If you include resources using a directory reference, the PNG crushing will not be performed by Xcode and you will have to do this manually.

You can crush all the PNGs in a directory manually using this little bash snippet:

find /path/to/directory -name "*.png" | while read filename; do
    xcrun -sdk iphoneos pngcrush -iphone "$filename" "${filename}_crushed"
    mv "${filename}_crushed" "${filename}"
done
like image 37
Mike Weller Avatar answered Dec 30 '22 11:12

Mike Weller