▲Original Image
▲Filtered Image
AppleScript名:画像にFalseColorFilterを実行してデスクトップにPNG形式で保存.scptd |
— Created 2017-02-05 by Takaaki Naganoya — 2017 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" use framework "AppKit" use framework "GPUImage" –https://github.com/BradLarson/GPUImage –Read JPEG file set aFile to POSIX path of (choose file of type {"public.image"}) set anImage to current application’s NSImage’s alloc()’s initWithContentsOfFile:aFile –Filter Image set stillImageFilter to current application’s GPUImageFalseColorFilter’s alloc()’s init() set aProcImg to stillImageFilter’s imageByFilteringImage:anImage –Make New File Name set aUUIDstr to (current application’s NSUUID’s UUID()’s UUIDString()) as string set aPath to ((current application’s NSString’s stringWithString:aFile)’s stringByDeletingLastPathComponent()’s stringByAppendingPathComponent:aUUIDstr)’s stringByAppendingPathExtension:"png" set sRes to saveNSImageAtPathAsPNG(aProcImg, aPath as string) of me –NSImageを指定パスにPNG形式で保存 on saveNSImageAtPathAsPNG(anImage, outPath) set imageRep to anImage’s TIFFRepresentation() set aRawimg to current application’s NSBitmapImageRep’s imageRepWithData:imageRep set pathString to current application’s NSString’s stringWithString:outPath set newPath to pathString’s stringByExpandingTildeInPath() set myNewImageData to (aRawimg’s representationUsingType:(current application’s NSPNGFileType) |properties|:(missing value)) set aRes to (myNewImageData’s writeToFile:newPath atomically:true) as boolean return aRes –true/false end saveNSImageAtPathAsPNG |