3 Replies Latest reply: Jul 13, 2012 4:44 AM by Muppet Mark RSS

    Convert Image Using Script (JSX)

    Harsh V Sharma Community Member

      Hi All,

       

      I want to convert a AI file into a JPEG by using JSX(java script)

      i am able to change its file type but having some problem with resizing

      can anyone please suggest me some solution.

       

      Thanks

        • 1. Re: Convert Image Using Script (JSX)
          Muppet Mark Community Member

          You can easily export a document to *.jpeg format using extendscript… There are options for horizontal and vertical scales what you can't alter by script is the resolution always 72dpi

          • 2. Re: Convert Image Using Script (JSX)
            Harsh V Sharma Community Member

            Thanks Mark

             

            But i want to change the size of input AI while converting it to JPEG

            this is all i want to do.

             

            i am using the following code:

             

            var docRef = app.activeDocument;

            var srcFile = app.activeDocument.fullName;

            var dstFile = app.activeDocument.path+"/"+app.activeDocument.name;

            //var dstFile = "D:/"+app.activeDocument.name;

            var ej = new ExportOptionsJPEG();

                ej.Optimization = true;

                ej.QualitySetting = 60;

                ej.blurAmount=0;

            for(var i=0; i<docRef.rasterItems.length;i++)

            {

                docRef.rasterItems[0].height=110;

            docRef.rasterItems[0].width=110;

            }

            docRef.exportFile(new File (dstFile), ExportType.JPEG, ej);

             

            but i am not sure this will work in every condition.

            i need a  perfect solution for it because some AI files mightnot have RasterItems in it, that will create a problem while resizing the document.

             

            Please guid me.

             

            Thanx

            • 3. Re: Convert Image Using Script (JSX)
              Muppet Mark Community Member

              I don't understand what exactly you are doing here? You have created a loop but only change the first raster[0]… you export after the loop so only one file… There are option to size in the export and you have not used them. I think a better description or a screen grab would help…