首页 » iOS UI资源 » PhotoShop 一键自动生成IOS所有尺寸的ICON

PhotoShop 一键自动生成IOS所有尺寸的ICON

作者: 低调的术木 分类: iOS UI资源, 电脑操作技巧 发布时间: 2015-05-20 16:19 ė浏览 2,240 次 6没有评论

支持iPhone 6 / 6 plus

设计完一张1024*1024的图标,再导出十几种用在iPhone, iPad, iTunes上不同尺寸的图标,过程繁琐笨重。

 

把下面代码 复制下来, 打开 记事本,保存为 ios_icon_save.jsx 
将文件保存在
C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)\Presets\Scripts
就是 ps安装目录下\Presets\Scripts 文件夹

重启PS. 就可以了。

使用时,在 文件 - 脚本 下就能找到。
我按自己习惯改了下。
自己想改,改 icons 那块就可以了, 添加自己想要的。
 

代码如下:

原文在这,Github

try
{
// Prompt user to select iTunesArtwork file. Clicking "Cancel" returns null.
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 = true;
doc.info = null; // delete metadata

//定义一个数组,这个数组由各种js对象组成,每个对象都有一个[name]属性和[size]属性,分别表示图标的名称的尺寸。
var icons = 
[
  {"name": "iTunesArtwork",  "size":1024},
  {"name": "icon-29",        "size":29},
  {"name": "icon-29@2x",     "size":58},
  {"name": "icon-29@3x",     "size":87},
  {"name": "icon-40",        "size":40},
  {"name": "icon-40@2x",     "size":80},
  {"name": "icon-40@3x",     "size":120},
  {"name": "icon-60",        "size":60},
  {"name": "icon-60@2x",     "size":120},
  {"name": "icon-60@3x",     "size":180},
  {"name": "icon-76",        "size":76},
  {"name": "icon-76@2x",     "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";
 
if ((icon.name == "iTunesArtwork@2x") || (icon.name == "iTunesArtwork"))
{
// iTunesArtwork files don't have an extension
destFileName = icon.name;
}
 
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
} 




本文出自 蓝天笔记,转载时请注明出处及相应链接。

本文永久链接: http://ubluesky.com/archives/801

0

发表评论

电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Ɣ回顶部