3 Replies Latest reply on May 1, 2013 11:35 PM by AnshuPATIL

    How can I tell the difference between a rasterized (in Illustrator) image and an embedded image?

    ArtistBrian

      Trying to determine via Javascript the difference between a file that has been rasterized in Illustrator and a file that has been embedded in Illustrator.  Best way I could think of was to check the rasterItem.file for the images, but the problem happens when I attempt to check the rasterItem.file of a rasterized-in-Illustrator file, I get the error kicked back "There is no file associated with this image" and it stops the script.

       

      I'm a relative newbie, and I don't know how to error-handle this.  Anyone have any suggestions?  Is there any other way to tell the difference between the files?

       

      Thanks in advance!

        • 1. Re: How can I tell the difference between a rasterized (in Illustrator) image and an embedded image?
          ArtistBrian Level 1

          Think I have it figured out with a try/catch statement, but if you have any other suggestions, I'd be more than willing to accept them!

          • 2. Re: How can I tell the difference between a rasterized (in Illustrator) image and an embedded image?
            AnshuPATIL

            var displayErrors = 1;

            var maxLines = 50;

            var bob = "";

            var disp_ar = new Array();

            //the item count object:

            var c = 0;

            var    observed  = prompt("What do you want to explore? i.e.;\r   app (not used before CS)\r   documents\r   activeDocument.pageItems[0]","activeDocument.selection[0]");

            //assign prompt text to actual object;

            //   a side effect of which is,

            //     if the user input is actually a line of executable code,

            //   it gets run here:

            var thisObject = eval(observed);

            try

            {

             

                for (all in thisObject )

                    {

                    c++;

                        //attempt to decypher each sub object

                    try

                        {

                            bob= all+"=";

                            bob+=  eval(observed+"."+all);

                            disp_ar.push(bob);

                           

                        }

                    catch (e)

                        {

                        // if undecypherable, say why:

                        if(displayErrors){

                            bob = all+"="+(e.toString().split(":"))[1];

                            disp_ar.push(bob);

                        }

                    }

                       

                        disp_ar.sort();

                }

                //decide arbitrary max length of list before switching to tabs.

             

               

                if(c>1){

                    // if object has more than one object content:

                    var nicedisp = "";

                    var dispLen = disp_ar.length;

                    // if longer than max, divide by the amount longer than max, so you don't

                    // end up with a dangling variable at the end.

                    var maxNum = dispLen>maxLines?dispLen/Math.ceil(dispLen/maxLines):maxLines;

                    var dispOutput = new Array("");

                    var more = "";

                    var myLoc = 0;

                    for (var x=0;x<dispLen;x++)

                    {

                        // add spacing for formatting of line numbers less that 10.

                        if(x<9 ){

                            spc = "  ";

                        } else{

                            spc = "";

                        }

                        var thisMod = Math.ceil(x%maxNum);

                        if(thisMod==true && x>maxNum -1){

                            myLoc++;

                            //initialize array slot:

                            dispOutput[myLoc] = "";

                        }

                       

                        dispOutput[myLoc]+=(spc+(x+1)+") "+disp_ar[x]+"\r");    

                    }

                    //show output page(s):

                    var outLen = dispOutput.length;

                    for (var a=0;a<outLen;a++)

                    {

                        more = a<(outLen-1)?"   More...":"";

                        alert("Contents of:\r"+observed+"\r------------------------\r"+dispOutput[a]+more);

                    }

               

                    

                }else{

                    alert("Value of:\r"+observed+"\r------------------------\r"+thisObject );

                }

                   

                }

            catch (e)

            {

                //if user is running code from command line, do nothing.

                //if object returns something, show it:

                if(thisObject!= undefined){

                    alert(thisObject);

                }

            }

            //handle spacing for columns

            function makeSpace(num){

                spc = "";

                for (var j=0;j<num ;j++ )

                {

                 spc+="|";

                }

                return spc;

            }