Image Crop Script

“How do I crop a Photo in Illustrator?” is the All-Time hottest topic in the Adobe Illustrator Forum, there’s a long thread with answers that go from “not possible”, to “use Photoshop”, to “use clipping masks”, to “use Artboards”. The thread also has the real answer to the question, cropping raster images in Illustrator is possible using a “cutter” path with a blending mode other than Normal, then Flattening Transparency. Great answer!! now this script tackles on the same principle as Flattening Transparency, it rasterizes the image within the bounds of the “cutter” path and discards what’s outside of the path bounds.

to use the script to Crop this image


draw a rectangle on top of the image to use as “cutter” path


select both, the image and the “cutter” path


run the imageCrop script


that’s all, the image gets cropped, embedded, unwanted pixels get discarded. If you don’t want your images to get destroyed, please use the other Masking methods.


Script Features

Press Shift Key before running the script to Rasterize using TypeOptimized option otherwise the script will use default ArtOptimized
Press Alt Key before running the script to Rasterize using custom Resolution, otherwise the script will use an average of the base image resolution.

Download imageCrop.jsx script

10 thoughts on “Image Crop Script

  1. Jaime is right, the script is rendering the images at 72 dpi .
    You can edit this behaviour by changing the “var resw and var resh” under “funktion objectResolution(obj)
    to you desired values.( line 55+56) . Just use notepad or any editor.

  2. Hi Carlos,
    really nice script, only learned about the technique through your explanation, but the script makes it even easier.
    Can’t really say what specifically triggers it, but one image (that I received already embedded, so no idea what they did to it) throws the following error when using the script, but not when cropping manually (I flatten with blend mode ‘darken’):
    Error 1239: Specified value greater than maximum allowed value
    Line: 45
    -> rasterOpts.resolution = objectResolution (image);
    As I said, I can crop that manually, just a heads up that that’s an error that can happen.

      1. I was able to replicate (well, more stumbled upon once again) by rotating images exactly or very close to +/-90° before trying to crop them. (88.25° was fine, 88.5° not) The threshold seemed to be independent of image size or aspect ratio (tested 100x100px and a 5000x7000px).
        I also noticed that, as I got very close to the threshold, computation time increased by a factor 10 or so, though that was only obvious with the larger image.
        Win7x64 with 8GB RAM, though if that should be relevant, it’s likely not on a level you have control over.

  3. Thank you for the script. But it can only crop rectangle shapes. And not custom shapes. Especially when using a pen tool to draw the specified shape to crop.

  4. Hi carlos.
    Great solution.
    It’s there any way to raster the image using original image ColorSpace or using original image resolution?

    1. Hi Jaime the script uses the original resolution unless you press Alt. About color space, let me see if there are any options for it.

      1. Hi Carlos. I see the script renders image at 72 dpi unless I change it pressing alt (AI CS5 and AI CC).
        About color, I would like the script detects if the image placed is grayscale or bitmap?
        Thank you

Leave a Reply

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