4 Replies Latest reply on Apr 2, 2017 11:35 PM by christophtrautbeck

    EPS files keep interrupting batch process? asks to Save As... asks to rasterize image.

    Lorin Lochridge Level 1

      Alright, so I am running this script that essentially opens all the files in a folder. It is supposed to take each of those images and check if they are eps, if they are it makes sure they are CMYK, if they are not it makes them CMYK.

      All files (after they go through this check) are put on a square canvas (height x width are equal based on the largest side).

      After this is done they are simply supposed to save, and close.

       

      That's it, should be super simple. HOWEVER

      I keep getting these issues:

      first I open my folder, that does a few images perfect then we get to an EPS (that is "generic EPS" instead of "Photoshop EPS") and it starts this:

      Screen Shot 2016-01-22 at 3.34.16 PM.png

       

      so I hit OK then:

       

      Screen Shot 2016-01-22 at 3.34.34 PM.png

       

      Then for some reason instead of saving like a normal file it wants to save it as a psd!!

      My action told it to save, not save as. Frustrating. This interrupts my batch and ruins the point of trying to batch this whole thing. I would have to sit here and babysit every image to ensure it's not getting interrupted by these two issues.

       

      My script is below.

       

      try {
        var data = GetDataFromDocument( activeDocument );
        if ('eps' == data.extension.toLowerCase()) {
        //convert to cmyk
        converToCMYK ( rasterize = true ) ;  
        toSquare();
        saveQuit();
        }
        else{
        //run code to square up images
        toSquare();
        saveQuit();
        }
      }
      catch( e ) {
        alert(e);
      }
      
      
      
      
      
      
      //FUNCTIONS
      ///////////////////////////////////////////////
      ///////////////////////////////////////////////
      
      
      function toSquare(){
        var savedRuler= app.preferences.rulerUnits;
        app.preferences.rulerUnits = Units.PIXELS;
        var w = app.activeDocument.width;
        var h = app.activeDocument.height;
        if(w>h) app.activeDocument.resizeCanvas (w, w, AnchorPosition.MIDDLECENTER);
        if(w<h) app.activeDocument.resizeCanvas (h, h, AnchorPosition.MIDDLECENTER);
        //if w==h already square
        app.preferences.rulerUnits = savedRuler;
      }
      
      
      ///////////////////////////////////////////////
      
      
      function GetDataFromDocument( inDocument ) {
        var data = new Object();
        var fullPathStr = inDocument.fullName.toString();
        var lastDot = fullPathStr.lastIndexOf( "." );
        var fileNameNoPath = fullPathStr.substr( 0, lastDot );
        data.extension = fullPathStr.substr( lastDot + 1, fullPathStr.length );
        var lastSlash = fullPathStr.lastIndexOf( "/" );
        data.fileName = fileNameNoPath.substr( lastSlash + 1, fileNameNoPath.length );
        data.folder = fileNameNoPath.substr( 0, lastSlash );
        data.fileType = inDocument.fullName.type;
        return data;
      }//
      
      function GetDataFromDocument( inDocument ) {
        var data = new Object();
        var fullPathStr = inDocument.fullName.toString();
        var lastDot = fullPathStr.lastIndexOf( "." );
        var fileNameNoPath = fullPathStr.substr( 0, lastDot );
        data.extension = fullPathStr.substr( lastDot + 1, fullPathStr.length );
        var lastSlash = fullPathStr.lastIndexOf( "/" );
        data.fileName = fileNameNoPath.substr( lastSlash + 1, fileNameNoPath.length );
        data.folder = fileNameNoPath.substr( 0, lastSlash );
        data.fileType = inDocument.fullName.type;
        return data;
      }
      
      
      ///////////////////////////////////////////////
      
      
      function converToCMYK( rasterize )  
      {  
          var idCnvM = charIDToTypeID( "CnvM" );  
          var desc39 = new ActionDescriptor();  
          var idT = charIDToTypeID( "T   " );  
          var idCMYM = charIDToTypeID( "CMYM" );  
          desc39.putClass( idT, idCMYM );  
          var idMrge = charIDToTypeID( "Mrge" );  
          desc39.putBoolean( idMrge, false );  
          var idRstr = charIDToTypeID( "Rstr" );  
          desc39.putBoolean( idRstr, rasterize );  
          executeAction( idCnvM, desc39, DialogModes.NO );  
      }  
        
      
      
      //////////////////////////////////////////////
      
      
      function saveQuit(){
        var quitOut  = app.doAction("saveQuit", "Commands.atn");
        return quitOut;
      }
      
      
      //////////////////////////////////////////////
      
      
      
      
      
      
      //////////////////////////////////////////////
      //////////////////////////////////////////////
      

       

       

      Please, any help would be very appreciated.

        • 1. Re: EPS files keep interrupting batch process? asks to Save As... asks to rasterize image.
          oliverIntergrafika Level 2

          Till You can get a final solution You should study the ADOBE PHOTOSHOP CC JAVASCRIPT SCRIPTING REFERENCE:

           

          http://www.adobe.com/content/dam/Adobe/en/devnet/photoshop/pdfs/photoshop-cc-javascript-re f.pdf

           

          Application.open() page 49.

          Application.saveAs() page 93.

          EPSOpenOptions page 103.

          EPSSaveOptions page 104.

          • 2. Re: EPS files keep interrupting batch process? asks to Save As... asks to rasterize image.
            christophtrautbeck

            Hello Lorin Lochridge,

             

            I know it been a while, but I am stuck with almost the same problem.

            I don't want this window to appear when saving a eps file via script.

             

            epsSaveOptionsWindow.JPG

             

            Did you find a solution or a workaround?

            Any help would be highly appreciated!

             

            Thanks in advance,

            Christoph

            • 3. Re: EPS files keep interrupting batch process? asks to Save As... asks to rasterize image.
              Lorin Lochridge Level 1

              My memory is fairly vague on the details, but this is what my final script ended up to be:

              (hope that helps)

               

              try {

                var data = GetDataFromDocument( activeDocument );

                if ('eps' == data.extension.toLowerCase()) {

                //convert to cmyk

                converToCMYK ( rasterize = true ) ; 

                toSquare();

                epsSave();

                }

                else{

                //run code to square up images

                toSquare();

                saveQuit();

                }

              }

              catch( e ) {

                alert(e);

              }

               

               

               

               

               

               

              //FUNCTIONS

              ///////////////////////////////////////////////

              ///////////////////////////////////////////////

               

               

              function toSquare(){

                var savedRuler= app.preferences.rulerUnits;

                app.preferences.rulerUnits = Units.PIXELS;

                var w = app.activeDocument.width;

                var h = app.activeDocument.height;

                if(w>h) app.activeDocument.resizeCanvas (w, w, AnchorPosition.MIDDLECENTER);

                if(w<h) app.activeDocument.resizeCanvas (h, h, AnchorPosition.MIDDLECENTER);

                //if w==h already square

                app.preferences.rulerUnits = savedRuler;

              }

               

               

              ///////////////////////////////////////////////

               

               

              function GetDataFromDocument( inDocument ) {

                var data = new Object();

                var fullPathStr = inDocument.fullName.toString();

                var lastDot = fullPathStr.lastIndexOf( "." );

                var fileNameNoPath = fullPathStr.substr( 0, lastDot );

                data.extension = fullPathStr.substr( lastDot + 1, fullPathStr.length );

                var lastSlash = fullPathStr.lastIndexOf( "/" );

                data.fileName = fileNameNoPath.substr( lastSlash + 1, fileNameNoPath.length );

                data.folder = fileNameNoPath.substr( 0, lastSlash );

                data.fileType = inDocument.fullName.type;

                return data;

              }

               

               

              ///////////////////////////////////////////////

               

               

              function converToCMYK( rasterize ) 

                  var idCnvM = charIDToTypeID( "CnvM" ); 

                  var desc39 = new ActionDescriptor(); 

                  var idT = charIDToTypeID( "T   " ); 

                  var idCMYM = charIDToTypeID( "CMYM" ); 

                  desc39.putClass( idT, idCMYM ); 

                  var idMrge = charIDToTypeID( "Mrge" ); 

                  desc39.putBoolean( idMrge, false ); 

                  var idRstr = charIDToTypeID( "Rstr" ); 

                  desc39.putBoolean( idRstr, rasterize ); 

                  executeAction( idCnvM, desc39, DialogModes.NO ); 

               

               

               

              //////////////////////////////////////////////

               

               

              function saveQuit(){

                var quitOut  = app.doAction("saveQuit", "Commands.atn");

                return quitOut;

              }

               

               

              //////////////////////////////////////////////

               

               

              function epsSave() {

                var doc = app.activeDocument;

                var docName = doc.name;

                docName = docName.match(/(.*)(\.[^\.]+)/) ? docName = docName.match(/(.*)(\.[^\.]+)/):docName = [docName, docName];

                var suffix = '_300';

                var saveName = new File(decodeURI(doc.path)+'/'+docName[1]+suffix+'.eps');

                saveFile( app.activeDocument, saveName );

              }

               

               

              function saveFile( doc, saveFile ) { 

                   var saveOptions = new EPSSaveOptions( ); 

                   saveOptions.embedColorProfile = true;

                   saveOptions.BINARY;

                   saveOptions.halftoneScreen = false;

                   saveOptions.interpolation = false;

                   saveOptions.psColorManagement = false;

                   saveOptions.transferFunction = false;

                   saveOptions.vectorData = false;

                   doc.saveAs( saveFile, saveOptions, true ); 

              }

              1 person found this helpful
              • 4. Re: EPS files keep interrupting batch process? asks to Save As... asks to rasterize image.
                christophtrautbeck Level 1

                Thanks a lot!

                You solved my problem!

                 

                If anybody else will read this thread in the future, this is why the window kept appearing:

                 

                My initial saveOptions (window appears):

                var saveOptions = new EPSSaveOptions();

                saveOptions.embedColorProfile = true;

                saveOptions.encoding = SaveEncoding.JPEGMAXIMUM;

                saveOptions.halftoneScreen = true;

                saveOptions.interpolation = true;

                saveOptions.preview = Preview.EIGHTBITTIFF;

                saveOptions.psColorManagement = true;

                saveOptions.transferFunction = true;

                saveOptions.transparentWhites = true;

                saveOptions.vectorData = true;

                aktDoc.flatten();

                aktDoc.saveAs(new File(whereToSave), saveOptions, false);

                 

                My "new" saveOptions (window does not appear anymore):

                var saveOptions = new EPSSaveOptions( );

                saveOptions.embedColorProfile = true;

                saveOptions.BINARY;

                saveOptions.halftoneScreen = true;

                saveOptions.interpolation = true;

                saveOptions.psColorManagement = true;

                saveOptions.transferFunction = true;

                saveOptions.vectorData = true;

                aktDoc.saveAs(new File(whereToSave), saveOptions, true);

                 

                I found out that the window does not appear anymore after I removed the option "transparentWhites".

                 

                Thanks again!