import objc, os, math from Foundation import * from AppKit import * ACScriptSuperMenuTitle = None ACScriptMenuTitle = "New Image With Frame and Drop Shadow" def main(image): doc = NSDocumentController.sharedDocumentController().currentDocument() data = doc.dataRepresentationOfType_('public.tiff') nsimg = image.NSImage() extent = image.extent() originalSize = extent[1] newSize = (originalSize[0] + 20, originalSize[1] + 20) newImage = NSImage.alloc().initWithSize_(newSize) newImage.lockFocus() NSColor.whiteColor().set() shadow = NSShadow.alloc().init() shadow.setShadowColor_(NSColor.blackColor().colorWithAlphaComponent_(.5)) shadow.setShadowOffset_((3, -3)) shadow.setShadowBlurRadius_(5) shadow.set() NSBezierPath.bezierPathWithRect_(((5,5), (newSize[0] - 10, newSize[1] - 10))).fill() # reset the shadow NSShadow.alloc().init().set() nsimg.drawAtPoint_fromRect_operation_fraction_((10, 10), NSZeroRect, NSCompositeCopy, 1.0); newImage.unlockFocus() NSDocumentController.sharedDocumentController().newDocumentWithImageData_(newImage.TIFFRepresentation()) # we're not changing the image, so we'll return nothing to put on return None