'What does it determine the placedItem.width and placedItem.height , when adding one without specifying those properties?
I'm in Adobe Illustrator 2022 26.064 and I'm placing an item. It is the thirdone I place in the same document.
var placedItem3 = doc.placedItems.add();
placedItem3.file = new File("/c/files/dotfiles-win/illustrator-scripts/lorem-picsum/3to2-1080x720.jpg");
placedItem3.name = "placedItem3";
For some reason it gets placedItem.width=3061,41 ,placedItem.height=2040,94
When the file is 1080x720
The previous items were placed keeping the same dimensions of the file.
Solution 1:[1]
You can find out ppi of a image with the formula:
72 / image.matrix.mValueA
For example here is the script that finds images with ppi less than 250 and selects them:
var min = 250; // target ppi
var rasters = app.activeDocument.rasterItems;
var i = rasters.length;
while (i--) if (72/rasters[i].matrix.mValueA < min) rasters[i].selected = true;
Illustrator does it in a rather uncommon way via the transformation matrix
I'm not sure if there are another ways as well. And probably it might require additional steps for rotated images.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
