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

Major Derp: Get Dimensions of Placed Image

Community Beginner ,
Jul 06, 2011 Jul 06, 2011

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.

TOPICS
Scripting

Views

419

Translate

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
Explorer ,
Jul 07, 2011 Jul 07, 2011

Copy link to clipboard

Copied

LATEST

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));

Votes

Translate

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