I am using MacIntosh X, Adobe Illustrator CS6 (version 16) and Applescript Editor (version 2.5).
I have more than 200 files with charts. Every Time I have to convert the color mode to GrayScale through Menu Bar.(Edit > Edit colors > Convert to GrayScale). After doing that I have to round of the Shade Percentage.
For example
70.40% to 70% (the value after the dot is below 50)
70.60 to 71% (the value after the dot is above 50)
Perhaps the best, I think is to use AppleScript Objective C although there are many other alternatives. But, it also depends on how you want to crop the files. I would look for this post by Shane Stanley, but I think I have his script somewhere. It uses AppleScript Objective C and is very quick. For thousands of photos you might want something like that that is quick and down to it.
Found it. I think this was the first post by Shane Stanley. Still need to look into the updates:
cropPic
set {thisFile, exportFile} to current application's NSApp's passedValue() as list
set theImage to current application's NSImage's alloc()'s initWithContentsOfFile:thisFile
set theSize to (theImage's |size|()) as record
set theHeight to height of theSize
set theWidth to width of theSize
set newRect to {{x:theWidth / 4, y:theHeight / 4}, {width:theWidth / 2, height:theHeight / 2}}
theImage's lockFocus()
set theRep to current application's NSBitmapImageRep's alloc()'s initWithFocusedViewRect:newRect
theImage's unlockFocus()
set theData to theRep's representationUsingType:(current application's NSJPEGFileType) |properties|:{NSImageCompressionFactor:0.9}
theData's writeToFile:exportFile atomically:true
end script
set thisFile to POSIX path of "Macintosh HD:Users:TL:desktop:Ski Images:whitefishT.jpg"
set exportFile to POSIX path of "Macintosh HD:Users:TL:desktop:Ski Images:whitefish.jpg"
The thing is, I was thinking is that if you want all your cropped photos to have the same dimensions. Then, something like this would be good. Still looking at my updates.
Here’s the second update. I think it was my update to generalize Shane’s library script for an individual:
set thisFile to POSIX path of "Macintosh HD:Users:TL:desktop:Ski Images:whitefishT.jpg"
set exportFile to POSIX path of "Macintosh HD:Users:TL:desktop:Ski Images:whitefish.jpg"
set theImage to current application's NSImage's alloc()'s initWithContentsOfFile:thisFile
set theSize to (theImage's |size|()) as record
set theHeight to height of theSize
set theWidth to width of theSize
set newRect to {{x:theWidth / 4, y:theHeight / 4}, {width:theWidth / 2, height:theHeight / 2}}
theImage's lockFocus()
set theRep to current application's NSBitmapImageRep's alloc()'s initWithFocusedViewRect:newRect
theImage's unlockFocus()
set theData to theRep's representationUsingType:(current application's NSJPEGFileType) |properties|:{NSImageCompressionFactor:0.9}
theData's writeToFile:exportFile atomically:true
There’s still more updates and looking into those.
On the side, here’s a script to run the library script above. But. you don’t need it nowdays because an AppleScript can contain AppleScript Objective C code:
use cropScript : script "CropFileToFilelib"
use scripting additions
-- choose the file to crop
set f to (choose file)
set pp to POSIX path of f
-- create file specification for new file
set desk_path to POSIX path of (path to desktop)
set fs to desk_path & "NewFile.png"
-- {x1, y1, x2, y2} origin is upper left
cropScript's cropTo:{100, 200, 500, 500} fromPath:(pp) toPath:(fs)
But, you see how you can adjust the dimensions. I think there is one more update.
I don’t know what this script adds and will need to look into it further, but it looks about the same as the one above:
use resizeScript : script "ResizeFileToFilelib"
use scripting additions
-- choose the file to resize
set f to (choose file)
set pp to POSIX path of f
-- create file specification for new file
set desk_path to POSIX path of (path to desktop)
set fs to desk_path & "NewFile.png"
-- {x1, y1, x2, y2} origin is upper left
resizeScript's resizeTo:{1440, 900} fromPath:(pp) toPath:(fs)
Your guess is a good as mine as to what I was thinking.
I am extremely sorry for the late reply. I left out office without logout this forum. Just now only I came. I check it and let you know if any queries.
Hi. Yes, there are ways to round and reset colors in AI using AppleScript, and there have been a few recent posts about doing the latter. The rounding can be performed simply by the round standard addition. Please show your code efforts for additional help.