Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
3

document.rasterize() crashing illustrator

Community Beginner ,
Jan 31, 2024 Jan 31, 2024

Copy link to clipboard

Copied

Hello,

I've been trying to use a jsx script to rasterize a specific layer called Artwork. This is my script below. Everytime I try to trigger the script, it crashes Illustrator. I've narrowed it down to the last line of code that seems to be crashing it, but that is the only line of code I can see in the scripting doc that will do what I need it to.

I'm using Illustrator 2022 but I've also tried it on 2023 and that also doesn't work. I don't suppose this is a glitch is it or is my script wrong? 

Thanks very much.


 

var doc = app.activeDocument;

 

var sourceArt = doc.layers.getByName("Artwork");
var clipBounds = undefined;

 

// Rasterization options
var options = new RasterizeOptions();
options.resolution = 300;
options.antiAliasingMethod.TYPEOPTIMIZED;
options.transparency = true;
options.convertSpotColors = false;
options.includeLayers = true;

 

// Rasterize layers with options
doc.rasterize(sourceArt, clipBounds, options);

TOPICS
Bug , Scripting

Views

351
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Jan 31, 2024 Jan 31, 2024

I presume "sourceArt" should be a vector item, not a layer. 

Votes

Translate
Adobe
Guide ,
Jan 31, 2024 Jan 31, 2024

Copy link to clipboard

Copied

I presume "sourceArt" should be a vector item, not a layer. 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 31, 2024 Jan 31, 2024

Copy link to clipboard

Copied

Yes @femkeblanco is right. Document.rasterize crashes if you give it a Layer or even PageItems objects.

 

This works:

var sourceArt = doc.layers.getByName("Artwork").pageItems[0];

- Mark 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 01, 2024 Feb 01, 2024

Copy link to clipboard

Copied

Thanks very both of you, that worked. Really appreciate your help!

Do you know if there is a simple way to rasterize everything within that layer? I've grouped it and that seems to do the trick, but just wondering if I can target the full layer without grouping.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 01, 2024 Feb 01, 2024

Copy link to clipboard

Copied

LATEST

I can't think of a simpler way than moving objects into group (temporarily). There is another approach, which is probably *less* simple which is to script a whole artboard export. Or a quick, png version is Document.imageCapture:.

var doc = app.activeDocument,
    bounds = doc.artboards[0].artboardRect,
    f = File(Folder.desktop + '/test.png'),
    options = new ImageCaptureOptions();

options.antiAliasing = true;
options.resolution = 500;
options.transparency = false;

doc.imageCapture(f, bounds, options);

Then you would have to place/embed the exported image depending on what you wanted.

 

But, no, I think the grouping method would be simplest.

- Mark

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines