Created
June 4, 2015 10:51
-
-
Save splitbrain/9ff65a2898ab3ad6ceac to your computer and use it in GitHub Desktop.
Revisions
-
splitbrain created this gist
Jun 4, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ #!/usr/bin/php <?php /** * Very simple script to convert iOS xcode imageset directories to DIP buckets * for Android development */ if(!isset($argv[2])) { die("Usage: ios2and.php <ios image asset folder> <android res folder>\n"); } $ios = $argv[1]; $and = $argv[2]; foreach(glob("$ios/*.imageset/Contents.json") as $jsonfile) { $setdir = dirname($jsonfile); $setname = basename($setdir, '.imageset'); $setname = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $setname)); $json = json_decode(file_get_contents($jsonfile), true); foreach($json['images'] as $img) { switch(strtolower($img['scale'])) { case '1x': $dip = 'mdpi'; break; case '2x': $dip = 'xhdpi'; break; case '3x': $dip = 'xxhdpi'; break; default: continue; } if(!$img['filename']) continue; $from = "$setdir/".$img['filename']; $to = "$and/drawable-$dip/$setname.png"; #FIXME handle extensions @mkdir(dirname($to), 0777, true); copy($from, $to); echo "$from -> $to\n"; } }