Skip to content

Instantly share code, notes, and snippets.

@douglashill
Created September 14, 2013 16:55
Show Gist options
  • Save douglashill/6563622 to your computer and use it in GitHub Desktop.
Save douglashill/6563622 to your computer and use it in GitHub Desktop.
Commands Acorn to export an iOS app icon in all useful sizes for iOS 6 and iOS 7. As written, this script assumes there is a square image named icon.acorn on my desktop, and writes the output files to the desktop. Flattening is performed inside the loop because it did not work when I put it outside. No changes are made to the original file, alth…
var sizes = [29, 40, 50, 57, 58, 72, 76, 80, 100, 114, 120, 144, 152, 1024];
var acorn = JSTalk.application("Acorn");
var doc = acorn.open("/Users/Douglas/Desktop/icon.acorn");
for (idx = 0; idx < sizes.length; idx++) {
doc.flattenImage();
doc.scaleImageToWidth(sizes[idx]);
doc.dataRepresentationOfType("public.png").writeToFile("/Users/Douglas/Desktop/icon-" + sizes[idx] + ".png");
doc.undo();
}
doc.close();
@ccgus
Copy link

ccgus commented Jan 8, 2014

pst:
doc.flattenImage(nil);
that should be more reliable, even though it's a private api.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment