Photoshop脚本代码一键生成所有cocos2d项目下的IOS图标

Copy to path:
MAC: /Applications/Adobe Photoshop CS5/Presets/Scripts
PC: c:\program files\Adobe Photoshop CS5\Presets\Scripts

// Turn debugger on. 0 is off. // $.level = 1; try { var iTunesArtwork = File.openDialog("Select a sqaure PNG file that is at least 1024x1024.","*.png",false); if (iTunesArtwork !== null) { var doc = open(iTunesArtwork,OpenDocumentType.PNG); if (doc == null) { throw "Something is wrong with the file. Make sure it's a valid PNG file."; } var startState = doc.activeHistoryState; // save for undo var initialPrefs = app.preferences.rulerUnits; // will restore at end app.preferences.rulerUnits = Units.PIXELS; // use pixels if (doc.width != doc.height) { throw "Image is not square"; } else if ((doc.width < 1024) && (doc.height < 1024)) { throw "Image is too small! Image must be at least 1024x1024 pixels."; } else if (doc.width < 1024) { throw "Image width is too small! Image width must be at least 1024 pixels."; } else if (doc.height < 1024) { throw "Image height is too small! Image height must be at least 1024 pixels."; } // Folder selection dialog var destFolder = Folder.selectDialog( "Choose an output folder"); if (destFolder == null) { // User canceled,just exit throw ""; } // Save icons in PNG using Save for Web. var sfw = new ExportOptionsSaveForWeb(); sfw.format = SaveDocumentType.PNG; sfw.PNG8 = false; // use PNG-24 sfw.transparency = false; doc.info = null; // delete metadata //References: //http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/MobileHIG/IconsImages/IconsImages.html%23//apple_ref/doc/uid/TP40006556-CH14-SW2 var icons = [ {"name": "Icon-29","size":29},{"name": "Icon-40","size":40},{"name": "Icon-50","size":50},{"name": "Icon-57","size":57},{"name": "Icon-58","size":58},{"name": "Icon-72","size":72},{"name": "Icon-76","size":76},{"name": "Icon-80","size":80},{"name": "Icon-100","size":100},{"name": "Icon-114","size":114},{"name": "Icon-120","size":120},{"name": "Icon-144","size":144},{"name": "Icon-152","size":152},]; var icon; for (i = 0; i < icons.length; i++) { icon = icons[i]; doc.resizeImage(icon.size,icon.size,// width,height null,ResampleMethod.BICUBICSHARPER); var destFileName = icon.name + ".png"; doc.exportDocument(new File(destFolder + "/" + destFileName),ExportType.SAVEFORWEB,sfw); doc.activeHistoryState = startState; // undo resize } alert("iOS Icons created!"); } } catch (exception) { // Show degbug message and then quit if ((exception != null) && (exception != "")) alert(exception); } finally { if (doc != null) doc.close(SaveOptions.DONOTSAVECHANGES); app.preferences.rulerUnits = initialPrefs; // restore prefs }

相关文章

    本文实践自 RayWenderlich、Ali Hafizji 的文章《...
Cocos-code-ide使用入门学习地点:杭州滨江邮箱:appdevzw@1...
第一次開始用手游引擎挺激动!!!进入正题。下载资源1:从C...
    Cocos2d-x是一款强大的基于OpenGLES的跨平台游戏开发...
1.  来源 QuickV3sample项目中的2048样例游戏,以及最近《...
   Cocos2d-x3.x已经支持使用CMake来进行构建了,这里尝试...