Acorn: Filter to save icons for Dropbox usage

I’m adding Dropbox support to my storyboarding application, and I use Acorn from Flying Meat Software to do most of my graphic work.  A while back Gus Mueller (Mr. Flying Meat) posted a plugin to save Acorn native images in both retina display format and in “regular” format.  To submit an app to Dropbox you should provide them with 16×16, 64×64, and 128×128 icons.  What I did was take Gus’s plugin and created one to save an Acorn native image in these formats for Dropbox.

As Gus shared his code, so I share my little swizzle on his work: (file: Save@Dropbox.jstalk)

// This script requires Acorn 3.0 or later, and goes in your
// ~/Library/Application Support/Acorn/Plug-Ins/ folder

function main(ciimage, doc, layer) {
  // make sure the file is saved, and make sure it's saved
  // as an Acorn file.
  if (![doc fileURL] || !([[doc fileURL] pathExtension] == "acorn")) {
    return;
  }

  var path1 = [[[doc fileURL] path] stringByDeletingPathExtension] + "-16.png"
  var path2 = [[[doc fileURL] path] stringByDeletingPathExtension] + "-64.png"
  var path3 = [[[doc fileURL] path] stringByDeletingPathExtension] + "-128.png"

  // save our 128/128 first.
  [doc scaleImageToWidth:128];
  var opts = {'uti': 'public.png', 'file': path3};
  [doc webExportWithOptions:opts];

  // scale our image to 64x64 size and save it.
  [doc scaleImageToWidth:64]
  var opts = {'uti': 'public.png', 'file': path2};
  [doc webExportWithOptions:opts];

  // Now save our 16x16 image.
  [doc scaleImageToWidth:16]
  var opts = {'uti': 'public.png', 'file': path1};
  [doc webExportWithOptions:opts];

  // undo the scale
  [doc undo];
}

Leave a Reply

Your email address will not be published. Required fields are marked *