Skip to main content
Inspiring
January 1, 2025
Answered

Script/rasterize() creates 2 images without apparent reason.

  • January 1, 2025
  • 1 reply
  • 655 views

This has been puzzling me recently:

  • When I use rasterize() on my group with a resolution of up to 191dpi, it behaves as expected—the group is replaced by a single image object.
  • However, at 192dpi or higher, the group turns into two image objects: one "normal" and one blank.

It seems this issue relates to resolution size, as scaling the group down requires an even higher dpi for the problem to manifest.

You can replicate the issue by downloading my document. The script below will prompt you for a dpi value upon launch.

https://shared-assets.adobe.com/link/714aaccc-b774-47cd-48b8-43a24f04e870

 

 

 

function rastr() {
	var doc = app.activeDocument;
	var docLayers = doc.layers;
	var item = docLayers[0].groupItems[0];
	
	// 191 works. 192 creates two image objects for some reason?
	var rasterResolution = prompt("Raster Resolution:", "");
	
	// Raster Options
	var rasterOpts = new RasterizeOptions;
	rasterOpts.resolution = parseInt(rasterResolution);
	rasterOpts.antiAliasingMethod = AntiAliasingMethod.None;
	rasterOpts.backgroundBlack = false;
	rasterOpts.clippingMask = false;
	rasterOpts.colorModel = RasterizationColorModel.DEFAULTCOLORMODEL;
	rasterOpts.convertTextToOutlines = false;
	rasterOpts.includeLayers = false;
	rasterOpts.padding = 0;
	rasterOpts.transparency = false;
	rasterOpts.convertSpotColors = true;
	
	doc.rasterize (item,item.geometricBounds, rasterOpts);
}
rastr();

 

 

 

Correct answer m1b

I have lodged a bug report. Please vote to have it fixed.

1 reply

m1b
Community Expert
Community Expert
January 2, 2025

Hi @iLLMonkey I can confirm your finding on AI 29.1 MacOS 15.2. It creates two images; one is just empty transparent pixels.

 

I will file a bug report. Also I've simplified the demo document (attached) to just two ordinary rectangles and modified your test code slightly just to be more targeted.

- Mark

 

 

(function () {

    var doc = app.activeDocument;
    var item = doc.groupItems[0];

    // Raster Options
    var rasterOpts = new RasterizeOptions;
    rasterOpts.resolution = 192;
    rasterOpts.antiAliasingMethod = AntiAliasingMethod.None;
    rasterOpts.backgroundBlack = false;
    rasterOpts.clippingMask = false;
    rasterOpts.colorModel = RasterizationColorModel.DEFAULTCOLORMODEL;
    rasterOpts.convertTextToOutlines = false;
    rasterOpts.includeLayers = false;
    rasterOpts.padding = 0;
    rasterOpts.transparency = false;
    rasterOpts.convertSpotColors = true;

    doc.rasterize(item, item.geometricBounds, rasterOpts);

    var count = doc.rasterItems.length;

    if (count > 1)
        alert('The rasterization created two images but should have created only one.');

})();

 

 

m1b
Community Expert
m1bCommunity ExpertCorrect answer
Community Expert
January 2, 2025

I have lodged a bug report. Please vote to have it fixed.