Answered
Script/rasterize() creates 2 images without apparent reason.
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();
