Copy link to clipboard
Copied
How to use applescript's rasterize, and how to set the parameters inside, I haven't found it after searching for a long time, please help
Yeah, that `rasterize` command is really poorly designed. Alas, a lot of the newer commands in AI were added by engineers with limited understanding of AppleScript or good UI/UX design.
Here’s a simple example, to rasterize the entire document’s content at 72dpi:
tell application "Adobe Illustrator"
tell document 1
rasterize source art page items with options {resolution:72}
end tell
end tell
(There’s also the `export` command, if you want to save a document as PNG/JPEG/etc.)
Copy link to clipboard
Copied
Yeah, that `rasterize` command is really poorly designed. Alas, a lot of the newer commands in AI were added by engineers with limited understanding of AppleScript or good UI/UX design.
Here’s a simple example, to rasterize the entire document’s content at 72dpi:
tell application "Adobe Illustrator"
tell document 1
rasterize source art page items with options {resolution:72}
end tell
end tell
(There’s also the `export` command, if you want to save a document as PNG/JPEG/etc.)
Copy link to clipboard
Copied
Thank you so much, but there is still a problem. When I tried to find multiple artboards, he only rasterized one of them, and the contents of the other artboards disappeared. I expect all artboards to be rasterize.
Also, I only recently started trying to use AppleScript, so I am not very familiar with this. I really appreciate your help.
Copy link to clipboard
Copied
By default, `rasterize` uses the bounds of artboard 1. You can specify a different area to rasterize via the `inside` parameter:
tell application "Adobe Illustrator"
tell document 1
set boundRect to {0, 1024, 2048, 0} -- {left,top,right,bottom} in points
rasterize source art page items with options {resolution:72} inside boundRect
end tell
end tell
Copy link to clipboard
Copied
Alternatively, for the `source art` parameter you can pass only the page items that lie on a specific artboard, leaving page items on other artboards untouched. Alas, AI doesn’t allow you to write `page items of artboard "NAME"`, which would be ideal, so you will have to figure out which page items lie on a particular artboard for yourself.
The easiest solution is to put each artboard’s content into a different layer while building the artwork, allowing you to write `rasterize source art page items of layer "NAME" …`. Otherwise, you’ll need get the bounding boxes of all path items in the document, then sort those into separate lists according to which artboard they lie on, although that’s more work to implement and will run slower.
I can’t really provide more specific recommendations without knowing more about your documents and why you want to rasterize them.