Skip to content

Instantly share code, notes, and snippets.

@voronoy
Created October 20, 2014 15:10
Show Gist options
  • Save voronoy/dc0426ca863f10b1421e to your computer and use it in GitHub Desktop.
Save voronoy/dc0426ca863f10b1421e to your computer and use it in GitHub Desktop.
Fireworks Command: Export App Icons
var dom = fw.getDocumentDOM();
var sizes = [
// ios
[57, 57, 'icon'],
[114, 114, 'icon@2x'],
[40, 40, 'icon-40'],
[80, 80, 'icon-40@2x'],
[50, 50, 'icon-50'],
[100, 100, 'icon-50@2x'],
[60, 60, 'icon-60'],
[120, 120, 'icon-60@2x'],
[72, 72, 'icon-72'],
[144, 144, 'icon-72@2x'],
[76, 76, 'icon-76'],
[152, 152, 'icon-76@2x'],
[29, 29, 'icon-small'],
[58, 58, 'icon-small@2x'],
// android
[128, 128, 'appicon'],
[96, 96, 'xhdpi'],
[72, 72, 'hdpi'],
[48, 48, 'mdpi'],
[36, 36, 'ldpi']
];
// delete all other pages
while (fw.getDocumentDOM().pagesCount > 1) {
fw.getDocumentDOM().deletePageAt(1);
}
for (var i = 0; i < sizes.length - 1; i++) {
// iterate over all required sizes
var width = sizes[i][0];
var height = sizes[i][1];
var name = sizes[i][2];
if (dom.width >= width || dom.height >= height) {
// duplicate, resize, rename
dom.duplicatePage(0);
dom.changeCurrentPage(1);
dom.setDocumentImageSize({left:0, top:0, right:width, bottom:height}, {pixelsPerUnit:72, units:'inch'}, true, -1);
dom.setPageName(1, name);
}
}
dom.changeCurrentPage(0);
//fw.exportDocumentAs(null, null, null);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment