You can use Image Events, which comes with Mac OS X to crop the image, if you do not have access to scripting for editing images (as in Photoshop). To get the dimensions of the image, just use something like the following ...
on GetImageDimensions(TheFile) -- (file path as string) as {width, height} try tell application "Image Events" launch --we have to launch Image Events before we can use it set theImage to open TheFile set theImageDimensions to dimensions of theImage set theImageWidth to item 1 of theImageDimensions set theImageHeight to item 2 of theImageDimensions return {theImageWidth, theImageHeight} end tell on error return {-1, -1}
... and the command to crop the image is as simple as
crop pathToFile to dimensions {cropWidth, cropHeight}
If, by chance, you have Photoshop, then cropping is handled differently:
crop pathToFile bounds {cropLeft, cropTop, cropRight, cropBottom}
The command is larger, but these are the required parameters. Other applications are more likely to have a different implementation (probably more like Apple). Simply select your image editing application and re-read the dictionary to find out how it works.
source share