Skip navigation
Currently Being Moderated

Resolution check in illustrator

Jul 2, 2012 3:07 AM

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

 
Replies
  • Currently Being Moderated
    Jul 2, 2012 10:32 AM   in reply to vinoth_mannu

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 3, 2012 9:07 AM   in reply to vinoth_mannu
     
    |
    Mark as:
  • Currently Being Moderated
    Jul 4, 2012 11:54 AM   in reply to vinoth_mannu

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 4, 2012 12:56 PM   in reply to CarlosCanto
    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…
     
    |
    Mark as:
  • Currently Being Moderated
    Jul 4, 2012 1:42 PM   in reply to Muppet Mark

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 4, 2012 5:51 PM   in reply to Muppet Mark

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 4, 2012 11:26 PM   in reply to vinoth_mannu

    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);
    
     
    |
    Mark as:
  • Currently Being Moderated
    Jul 6, 2012 7:46 AM   in reply to CarlosCanto

    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();
    
     
    |
    Mark as:
  • Currently Being Moderated
    Jul 5, 2012 9:39 AM   in reply to moluapple

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

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 6, 2012 9:11 AM   in reply to vinoth_mannu

    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.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points