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

Resolution check in illustrator

Explorer ,
Jul 02, 2012 Jul 02, 2012

Copy link to clipboard

Copied

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

TOPICS
Scripting

Views

16.4K

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

correct answers 1 Correct answer

Enthusiast , Jul 04, 2012 Jul 04, 2012

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

Votes

Translate

Translate
Adobe
Community Expert ,
Jul 02, 2012 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.

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

Copy link to clipboard

Copied

Thanks for the reply.

I hope this could be sovled in CS7?

regards,

Vinoth

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
Community Expert ,
Jul 03, 2012 Jul 03, 2012

Copy link to clipboard

Copied

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
Community Expert ,
Jul 04, 2012 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.

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
Guru ,
Jul 04, 2012 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…

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
Community Expert ,
Jul 04, 2012 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.

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
Community Expert ,
Jul 04, 2012 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.

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
Community Expert ,
Jul 05, 2012 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();

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
Enthusiast ,
Jul 04, 2012 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);

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
Community Expert ,
Jul 05, 2012 Jul 05, 2012

Copy link to clipboard

Copied

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

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

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
Community Expert ,
Jul 06, 2012 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.

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
Engaged ,
May 26, 2022 May 26, 2022

Copy link to clipboard

Copied

Great. You saved lot of time.

-Sumit

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
Community Expert ,
Mar 18, 2019 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

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
Enthusiast ,
Jun 06, 2020 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. 


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
Enthusiast ,
Jun 06, 2020 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.

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
Community Expert ,
Sep 27, 2024 Sep 27, 2024

Copy link to clipboard

Copied

LATEST

I know I'm late to the party here, and i wish i could be the dude who gives you an explanation for how and why this works..... but im completely baffled...

 

bumping this to the top to see if anyone else can shed some light.

 

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