Highlighted

Resolution check in illustrator

Explorer ,
Jul 02, 2012

Copy link to clipboard

Copied

How to check the raster image resolution in illustrator through script?

This seems to solve it:

// select a rasterItem, no rotation or skew

72/app.selection[0].matrix.mValueA;

// also

72/app.selection[0].matrix.mValueD;

// for rotation applied(no skew) item

var item = app.selection[0],

    matrix = item.matrix,

    rotation = 180/Math.PI * Math.atan2(matrix.mValueC, matrix.mValueD);

item.rotate(rotation);

alert(72/item.matrix.mValueA);

item.rotate(-rotation);

Topics

Scripting

Views

10.3K

Likes

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

Resolution check in illustrator

Explorer ,
Jul 02, 2012

Copy link to clipboard

Copied

How to check the raster image resolution in illustrator through script?

This seems to solve it:

// select a rasterItem, no rotation or skew

72/app.selection[0].matrix.mValueA;

// also

72/app.selection[0].matrix.mValueD;

// for rotation applied(no skew) item

var item = app.selection[0],

    matrix = item.matrix,

    rotation = 180/Math.PI * Math.atan2(matrix.mValueC, matrix.mValueD);

item.rotate(rotation);

alert(72/item.matrix.mValueA);

item.rotate(-rotation);

Topics

Scripting

Views

10.3K

Likes

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
Adobe Community Professional ,
Jul 02, 2012

Copy link to clipboard

Copied

No matter how many time someone asks, that information is not available to scripting in AI. There is no rasterItem.resolution property to look at.

Likes

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
Reply
Loading...
Explorer ,
Jul 03, 2012

Copy link to clipboard

Copied

Thanks for the reply.

I hope this could be sovled in CS7?

regards,

Vinoth

Likes

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
Reply
Loading...
Adobe Community Professional ,
Jul 03, 2012

Copy link to clipboard

Copied

Likes

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
Reply
Loading...
Adobe Community Professional ,
Jul 04, 2012

Copy link to clipboard

Copied

since you've ask a number of times I figure is kind of important for you. You've noticed you didn't get an answer, there's no navtive Resolution property in Illustrator....but there's hope, one way I think you can accoplish that is by using BridgeTalk to open the Illustrator file in photoshop....PS can easily get you the resolution and send it back to Illustrator.

Likes

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
Reply
Loading...
Guru ,
Jul 04, 2012

Copy link to clipboard

Copied

Carlos Im not sure that will help… If you open the *.ai file in photoshop its going to ask you to rasterise the lot… You could select the item in illustrator and app.copy() then paste in new document ps will default to the size of clipboard content… All very messy when you can just pre-flight in Acrobat… Both placedItem and rasterItem can have file properties but Im sure this relates to embedded which may or may not have a file…

Likes

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
Reply
Loading...
Most Valuable Participant ,
Jul 04, 2012

Copy link to clipboard

Copied

If this is as crucially important as the OP appears to think, taking the low road may help. Export to EPS and you got yourself an easily readable ASCII formatted text file that you can inspect at will.

By the way, as with all image formats that allow embedding one or *more* images into a single file, you cannot say anything about *every* embedded raster file at once -- you have to inspect each of them.

Likes

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
Reply
Loading...
Adobe Community Professional ,
Jul 04, 2012

Copy link to clipboard

Copied

Hi Mark, I opened the Ai file manually in PS and I got the "Import PDF" dialog where I chose "images". That brings the chosen image at its native resolution...

...then I tried with VBA (very easy to get AI and PS to talk to each other) and it worked as expected...

let me try with BridgeTalk...hope there's no issues.

Likes

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
Reply
Loading...
Adobe Community Professional ,
Jul 05, 2012

Copy link to clipboard

Copied

ok, here's the BridgeTalk version, it works with Linked or Embedded images...it was a good exercise, but I think Molouapple's version is more straightforward

var idoc = app.activeDocument;

var idocname = idoc.fullName;

//alert(idocname);

//$.writeln(idocname);

var bt = new BridgeTalk;

bt.target = "photoshop";

var msg = "\n" +

          "var pdfOpts = new PDFOpenOptions;\n" +

          "pdfOpts.page = 3;\n" +

          "var file = new File('" +idocname+"');\n" +

          "var idoc = app.open(file, pdfOpts);\n" +

          "resolution = idoc.resolution;\n"

bt.body = msg;

bt.onResult = function(resObj) {

          var res = resObj.body;

          alert("Resolution = " + res);

}

bt.send();

Likes

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
Reply
Loading...
Enthusiast ,
Jul 04, 2012

Copy link to clipboard

Copied

This seems to solve it:

// select a rasterItem, no rotation or skew

72/app.selection[0].matrix.mValueA;

// also

72/app.selection[0].matrix.mValueD;

// for rotation applied(no skew) item

var item = app.selection[0],

    matrix = item.matrix,

    rotation = 180/Math.PI * Math.atan2(matrix.mValueC, matrix.mValueD);

item.rotate(rotation);

alert(72/item.matrix.mValueA);

item.rotate(-rotation);

Likes

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
Reply
Loading...
Adobe Community Professional ,
Jul 05, 2012

Copy link to clipboard

Copied

Great job, Moluapple. Will be quite handy in the future.

Likes

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
Reply
Loading...
Explorer ,
Jul 06, 2012

Copy link to clipboard

Copied

Thanks for the script.

When we run this via illustrator saved files we get the alert of the document name only.

Could you please advice us how to proceed this script.

Likes

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
Reply
Loading...
Adobe Community Professional ,
Jul 06, 2012

Copy link to clipboard

Copied

If you want to use it on a file, you will have to use a loop which loops through the rasterImages in the file. Right now it requires the file to be open and a raster image selected.

Likes

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
Reply
Loading...
Adobe Community Professional ,
Mar 18, 2019

Copy link to clipboard

Copied

As a scripting newb, the following is beyond me, however I would do something like:

Embedded image pixel width, divided by physical width of image on canvas in inches = width ppi value

Embedded image pixel height, divided by physical height of image on canvas in inches = height ppi value

Pick the smallest value of the two (they should be close), one may need to round the value to the closest integer

Likes

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
Reply
Loading...
Engaged ,
Jun 06, 2020

Copy link to clipboard

Copied

Illustrator makes this difficult, and not straight forward... plus percentage math isn't my forte. One can read the percentage of the image from the matrix mValueB and C, but if it's Linked the percentage is based on the resolution of the image. So as an example, we get:

 

LINKED: W: 1800px | W": 25in" and Link Panel reads W: 3300px | Scale: 113% | Resolution: 132dpi

EMBEDDED: W: 1800px | W": 25in" and Link Panel reads W: 3300px | Scale: 54.6% | Resolution 132dpi

 

The source image in photoshop reads 150dpi, but being that DPI is not readable in AI, the image must be embedded and at 0 rotation and then one can find the original image size and DPI by doing some math.

(Wpx / Scale) * 100 = Original Wpx
(Original Wpx / Current Wpx) * 72 = DPI of Image. 


Likes

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
Reply
Loading...
Engaged ,
Jun 06, 2020

Copy link to clipboard

Copied

Now I see the beauty of Moluapple's first block of code. If someone has a quick breakdown as to why DPI/Scale % = Resolution, I'd appreciate it. Also, There doesn't seem to be a clear explanation in docs on what the matrix is comprised of. A and D, seem to be the decimal form of scale %, and I'd assume TX and TY are Transformation? That leaves mValueB and mValueC.

Likes

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
Reply
Loading...