Skip to content

Instantly share code, notes, and snippets.

@yoichitgy
Created March 13, 2015 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yoichitgy/7d34087f2871a61df8a3 to your computer and use it in GitHub Desktop.
Save yoichitgy/7d34087f2871a61df8a3 to your computer and use it in GitHub Desktop.
A shell script to generates screenshot images from PSD files to submit to iTunes Connect (App Store). It removes the alpha channel of the source 5.5 inch images, and resizes and crops them to generate 4.7, 4 and 3.5 inch images.
#!/bin/sh
# settings ==========
filePrefix=""
destDir="./output/"
destDir5_5=$destDir"5.5inch/"
destDir4_7=$destDir"4.7inch/"
destDir4=$destDir"4inch/"
destDir3_5=$destDir"3.5inch/"
# ====================
# create dest directory
mkdir $destDir
mkdir $destDir5_5
mkdir $destDir4_7
mkdir $destDir4
mkdir $destDir3_5
# loop for 5.5inch
echo "5.5inch"
for i in 1 2 3 4 5
do
destFilePath=$destDir5_5$filePrefix$i".png"
echo $destFilePath
convert $filePrefix$i".psd[0]" $destFilePath
convert $destFilePath -background white -flatten $destFilePath
done
# loop for 4.7inch
echo "4.7inch"
for i in 1 2 3 4 5
do
sourceFilePath=$destDir5_5$filePrefix$i".png"
destFilePath=$destDir4_7$filePrefix$i".png"
echo $destFilePath
convert -resize x1334 $sourceFilePath $destFilePath
done
# loop for 4inch
echo "4inch"
for i in 1 2 3 4 5
do
sourceFilePath=$destDir5_5$filePrefix$i".png"
destFilePath=$destDir4$filePrefix$i".png"
echo $destFilePath
convert -resize 640x $sourceFilePath $destFilePath
convert -crop 640x1136+0+0 $destFilePath $destFilePath
done
# loop for 3.5inch
echo "3.5inch"
for i in 1 2 3 4 5
do
sourceFilePath=$destDir4$filePrefix$i".png"
destFilePath=$destDir3_5$filePrefix$i".png"
echo $destFilePath
convert -crop 640x960+0+0 $sourceFilePath $destFilePath
done
@yoichitgy
Copy link
Author

@yoichitgy
Copy link
Author

To use the shell script:

  1. Install ImageMagick
  2. Prepare 1.psd, 2.psd, 3.psd, 4.psd and 5.psd in 1242 x 2208 pixels for 5.5 inch screen iPhone. The filenames can have a prefix defined as filePrefix in the script.
  3. Run the script where the PSD files are located.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment