Created
September 8, 2013 19:27
-
-
Save knunery/6487674 to your computer and use it in GitHub Desktop.
Powershell script I use to make all the images needed for IOS and Windows App development.
This file contains hidden or 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
# Create-Icons "C:\dropbox\projects\super8bitme\assets\super-8bit-me-art.png" "C:\temp" "windows" | |
Function Create-Icons | |
{ | |
param($sourceFile, $targeLocation, $platform = "ios") | |
#$targetFile = Join-Path -path "C:\Temp" -ChildPath iTunesArtwork.png | |
#convert $sourceFile -resize 512x512 $targetFile | |
if ($platform -eq "ios") | |
{ | |
$sizes = @{ "512x512"="iTunesArtwork"; | |
"1024x1024"="iTunesArtwork@2x"; | |
"57x57"="Icon"; | |
"114x114"="Icon@2x"; | |
"72x72"="Icon-72"; | |
"144x144"="Icon-72@2x"; | |
"29x29"="Icon-Small"; | |
"58x58"="Icon-Small@2x"; | |
"50x50"="Icon-Small-50"; | |
"100x100"="Icon-Small-50@2x"; | |
} | |
} | |
else{ | |
$sizes = @{ "50x50"="StoreLogo"; | |
"150x150"="Logo"; | |
"30x30"="SmallLogo"; | |
"620x300"="SplashScreen"; | |
"310x150"="WideLogo"; | |
"24x24"="BadgeLogo"; | |
"846x468"="PromoImage846x468"; | |
"558x756"="PromoImage558x756"; | |
"414x468"="PromoImage414x468"; | |
"414x180"="PromoImage414x180"; | |
} | |
} | |
foreach($key in $sizes.Keys) | |
{ | |
$size = $key | |
$filename = $sizes[$key] | |
$targetFile = (Join-Path -path "C:\Temp" -ChildPath $filename) + ".png" | |
convert $sourceFile -resize $size $targetFile | |
# http://www.imagemagick.org/Usage/crop/ | |
# helps with images that aren't square | |
# resize canvas to expected size and fill in black for the background | |
#convert $targetFile -background "black" -gravity center -extent $size $targetFile | |
convert $targetFile -background "#109fda" -gravity center -extent $size $targetFile | |
} | |
} | |
# example usage | |
# Create-Icons "C:\temp\largeImage.PNG" "C:\temp" "windows" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment