Created
June 2, 2013 15:16
-
-
Save gibtang/5693814 to your computer and use it in GitHub Desktop.
PHP script to auto create all the various iOS icons based on only 1 image. This requires ImageMagick to run http://www.imagemagick.org/script/index.php
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
<?php | |
$filename = $argv[1];//get the command line argument which is supposed to be the png filename | |
echo "Going to iconize \"$filename\"\n"; | |
class imgFile | |
{ | |
public $fileName; | |
public $size; | |
public function __construct($fileName, $size) | |
{ | |
$this->fileName = $fileName; | |
$this->size = $size; | |
} | |
} | |
$imgArray = array( | |
new imgFile("Icon-72.png","72x72"), | |
new imgFile("Icon-Small-50.png","50x50"), | |
new imgFile("Icon-Small.png","29x29"), | |
new imgFile("[email protected]","58x58"), | |
new imgFile("Icon.png","57x57"), | |
new imgFile("[email protected]","114x114") | |
); | |
$dest = "BugMath2/Resources/";//This is the path of where your iOS icon files are to reside | |
foreach ($imgArray as $img) | |
{ | |
//echo "$img->fileName $img->size\n"; | |
$size = $img->size; | |
$fileName = $img->fileName; | |
$str = "\nCreating $size size of icon"; | |
echo $str; | |
$response = shell_exec("convert $filename -resize $size $fileName"); | |
if (is_null($response) == false) | |
exit("\nError at creating icon of $size"); | |
else | |
echo "\nSuccess in creating icon of $size"; | |
echo "\nCopying $fileName over to $dest"; | |
shell_exec("cp $fileName $dest"); | |
echo "\n========"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use, just type "php createIcon.php someimage.png" and just sit back and grab a beer