Created
April 22, 2011 17:34
-
-
Save sharjeelaziz/937171 to your computer and use it in GitHub Desktop.
Generate ImageInfo.plist for all the images in the current directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Requires ImageMagick | |
# Updates ImageInfo.plist -- plist file should already exist | |
# and initialized as /usr/libexec/PlistBuddy -c "Clear array" ImageInfo.plist | |
IMAGEINFOFILE="ImageInfo.plist" | |
/usr/libexec/PlistBuddy -c "Clear array" $IMAGEINFOFILE | |
INDEX=0 | |
for f in *.png; | |
do | |
WIDTH=`identify $f | sed -E 's/.* ([0-9]+)x[0-9]+ .*/\1/'` | |
HEIGHT=`identify $f | sed -E 's/.* [0-9]+x([0-9]+) .*/\1/'` | |
echo "Processing $f $INDEX $WIDTH $HEIGHT" | |
/usr/libexec/PlistBuddy -c "Add :$INDEX:name string ${f/.png}" $IMAGEINFOFILE | |
/usr/libexec/PlistBuddy -c "Add :$INDEX:height real $HEIGHT" $IMAGEINFOFILE | |
/usr/libexec/PlistBuddy -c "Add :$INDEX:width real $WIDTH" $IMAGEINFOFILE | |
INDEX=`expr $INDEX + 1` | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment