Skip to content

Instantly share code, notes, and snippets.

@Umiiii
Last active February 13, 2020 13:27
Show Gist options
  • Save Umiiii/26406cf926e5c0a103cbc3e9ff097e83 to your computer and use it in GitHub Desktop.
Save Umiiii/26406cf926e5c0a103cbc3e9ff097e83 to your computer and use it in GitHub Desktop.
Resize the png file within the same directory into three different size that fit the iOS universal imageset
writeToJson(){
rm $1.imageset/Contents.json
echo "{
\"images\" : [
{
\"idiom\" : \"universal\",
\"filename\" : \"[email protected]\",
\"scale\" : \"1x\"
},
{
\"idiom\" : \"universal\",
\"filename\" : \"[email protected]\",
\"scale\" : \"2x\"
},
{
\"idiom\" : \"universal\",
\"filename\" : \"[email protected]\",
\"scale\" : \"3x\"
}
],
\"info\" : {
\"version\" : 1,
\"author\" : \"xcode\"
}
}" >> $1.imageset/Contents.json
}
resize(){
sips -z 72 72 $1.png --out [email protected]
sips -z 48 48 $1.png --out [email protected]
sips -z 24 24 $1.png --out [email protected]
}
copyToFolder(){
mkdir $1.imageset
cp [email protected] ./$1.imageset/
cp [email protected] ./$1.imageset/
cp [email protected] ./$1.imageset/
rm [email protected]
rm [email protected]
rm [email protected]
}
for file in `ls *.png`
do
resize ${file%.png}
copyToFolder ${file%.png}
DIR="./${file%.png}"
writeToJson $DIR ${file%.png}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment