“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.
Very helpful information thanks
Pingback: How to Crop in Illustrator: A Comprehensive Guide - backgroundillustration.online
Pingback: FREE Illustrator Scripts - Fonts Beast
The ImageCrop script download does not work?
Pingback: 7+ Amazing Free Illustrator Script | Doing This
it says error 1240 : specified value less than minimum value
what do i do?
Pingback: 6 consigli per lavorare più velocemente con Illustrator - Grafigata! Tutorial
Pingback: 7 FREE Illustrator Scripts (MUST HAVE) | Nikkies Tutorials
Thanks for the script it is awesome.. I made a change to it because holding the alt key was making the menu disappear in AI CC. I changed it the ctrlKey.
line 38 from:
if(ScriptUI.environment.keyboardState.altKey) { // press alt key to Enter a custom Resolution, otherwise use the image resolution
to:
if(ScriptUI.environment.keyboardState.ctrlKey) { // press ctrl key to Enter a custom Resolution, otherwise use the image resolution
note if you want to change the default resolution change lines 55 and 56 to reflect your dpi like 300 instead of 72.
the resolution listed on line 40 is just the default on the popup.
Lastly I could not get it to come up on the “file,scripts”. I had added the script to the wrong folder mine in a windows 10 setup using AI CC 2018 went in this folder: C:\Program Files\Adobe\Adobe Illustrator CC 2018\Presets\en_US\Scripts\
thanks for the script
Thank you very mach for this script! Very useful and work perfect! 🙂
This is very nice script. Is their any way to maintain transparency of object intact when cropped?
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.
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.
bw,
Tobl
Hi, thanks for letting me know, let me see if I can replicate the error
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.
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.
Hi carlos.
Great solution.
It’s there any way to raster the image using original image ColorSpace or using original image resolution?
Thanks
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.
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
Very clean and concise way to bring such a powerful solution, great work Carlos!
That is awesome, been hoping for something like this a long time. Keep up the great work!