Copy link to clipboard
Copied
Given a rectangle with a placed graphic, set fit proportional, How do I go about getting the actual height & width of my placed image?
My image is being scaled down to fit the box. I can see that in my output. I'm not sure which object(s) to query, and what properties to query to get the actual original image dimensions.
Thanks.
Copy link to clipboard
Copied
Hi,
Do you mean something like this:
var document = app.activeDocument;
document.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.POINTS;
document.viewPreferences.verticalMeasurementUnits = MeasurementUnits.POINTS;
var image = document.rectangles[0].images[0];
var link = image.itemLink;
var xScale = (image.effectivePpi[0] / 72);
var yScale = (image.effectivePpi[1] / 72);
$.writeln("Image: " + link.filePath);
$.writeln("Width: " + Math.floor((image.geometricBounds[3] - image.geometricBounds[1]) * xScale));
$.writeln("Height: " + Math.floor((image.geometricBounds[2] - image.geometricBounds[0]) * yScale));