Created
July 12, 2013 16:15
-
-
Save rixtox/5985670 to your computer and use it in GitHub Desktop.
You need to add executable privileges for icns.sh after the first time you run the command.
If you changed your project name, you need to remove icns.sh and rerun the command.
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
/*********************************** | |
Adobe Fireworks Command File | |
Auto export iconset with different | |
resolutions for icns generating. | |
Install into ~/Library/Application | |
Support/Adobe/Fireworks CS6/Commands | |
************************************ | |
The MIT License (MIT) | |
Copyright (c) 2013 RixTox | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in | |
all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
THE SOFTWARE. | |
***********************************/ | |
var dom = fw.getDocumentDOM() | |
, dir = Files.getDirectory(dom.filePathForSave) + "/" | |
, fullname = Files.getFilename(dom.filePathForSave) | |
, extension = Files.getExtension(dom.filePathForSave) | |
, filename = fullname.substring(0 | |
, fullname.lastIndexOf(extension)) | |
, outdir = dir + filename + ".iconset/" | |
, shdir = dir + "icns.sh" | |
, sizes = [16,32,128,256,512] | |
, scales = [1,2]; | |
if(!Files.isDirectory(outdir)) | |
Files.deleteFile(outdir); | |
if(!Files.exists(outdir)) | |
Files.createDirectory(outdir); | |
if(!Files.exists(shdir)) { | |
Files.deleteFileIfExisting(shdir); | |
Files.createFile(shdir, "TEXT", "FWMX"); | |
var batch_file = Files.open(shdir, true); | |
batch_file.write("iconutil -c icns \"./" + filename | |
+ ".iconset\" \"./" + filename + ".icns\""); | |
batch_file.close(); | |
} | |
for(var i in sizes) { | |
for( var j in scales) { | |
fw.exportDocumentAs(null, outdir + "icon_" | |
+ sizes[i] + "x" + sizes[i] + (scales[j]==2?"@2x":"") | |
+ extension, { | |
exportFormat: "PNG" | |
, colorMode: "32 bit" | |
, jpegQuality: 100 | |
, paletteMode: "exact" | |
, paletteTransparencyType: "index alpha" | |
, useScale: false | |
, applyScale: true | |
, xSize: (sizes[i] * scales[j]) | |
, ySize: (sizes[i] * scales[j]) | |
}); | |
} | |
} | |
alert("Finished.\nPlease add executable privileges to icns.sh file.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment