3 Replies Latest reply on Feb 22, 2012 7:18 AM by c.pfaffenbichler

    Saving without a popup

    Jonkel

      Hi!

      I'm making a batch script that is gonna take an original png image, save it to a image with RGB and an image with the alpha from the original image in the R channel.

      Now, I've gotten almost all the way there, there's just one thing left. Saving the files.

       

      Is there any way I can save as a specific filename, a specific filetype, and if possible change the number of bits in the PNG? (I only need the R channel in the alpha image).

       

          var origDoc = open(file);
          var rgbExtension = "_rgb";
          var alphaExtension = "_a";
          var rgbPage = documents.add(origDoc.width, origDoc.height, 72.0, origDoc.name + rgbExtension,NewDocumentMode.RGB, DocumentFill.WHITE);
          CopyWithEmptyPixels(origDoc, rgbPage);
      
          var alphaPage = documents.add(origDoc.width, origDoc.height, 72.0, origDoc.name + alphaExtension,NewDocumentMode.RGB, DocumentFill.WHITE);
          CopyFillAlphaBlack(origDoc, alphaPage);
      
          rgbPage.save(); // Doesn't work, crashes the script.
          alphaPage.saveAs (origDoc.path + alphaExtension); // Also doesn't work, crashes the script.
          alphaPage.close(SaveOptions.SAVECHANGES); // Does work, but throws a popup. And I have around 400 files I need to do this on. Can't really afford to have popups.
      

       

      I'm using javascript, photoshop cs5 and the extendscript toolkit CS5.