1 Reply Latest reply on Jul 18, 2016 9:25 AM by JJMack

    Faster saving of merged layers with transparency

    titpetric

      I'm using PS to generate PNG assets with transparency from a set of PDFs and source images. When timing one job, the jobs complete in about 10-12 seconds. I've been trying to dig into what makes this procedure so slow and added some debugging/logging to the JSX code:

       

      An example run has timings like this:

      ~~~

      [0] start

      [0.947] file open

      [1.53] recurse layers

      [1.53] replace start

      [2.138] replace end

      [2.14] loop + replace layers

      [11.215] exported

      [11.272] closed

      [11.272] save png

      ~~~

       

      Between 2.14sec and 11.215 sec I'm doing this:

       

      ~~~

      var pngFile = new File(filename);

       

      var exportOptions = new ExportOptionsSaveForWeb();

      exportOptions.format = SaveDocumentType.PNG;

      exportOptions.PNG8 = false;

      exportOptions.transparency = true;

      exportOptions.quality = 100;

      exportOptions.optimized = false;

      exportOptions.dither = Dither.NONE;

       

      doc.exportDocument(pngFile, ExportType.SAVEFORWEB, exportOptions);

      log("exported");

      doc.close(SaveOptions.DONOTSAVECHANGES);

      log("closed");

      ~~~

       

      Any way to speed this up? I assumed the settings are already optimal and I can't spot something I could turn off anymore. There are maybe 10-15 layers in total, size of resulting png is 5400x4800. Timing for a manual save to web (final step) from PS is about 4 seconds which is much less than measured here.

        • 1. Re: Faster saving of merged layers with transparency
          JJMack Most Valuable Participant

          PNG file format does not support layers so a merged composite would be saved.  How long it take Photoshop to render this composite will depend on the processing Photoshop need to do. Were smart object layers objects replace and so smart filters need to be applied to the replaced object rendered pixels. ETC.  Have you timed using Action Manager code instead of DOM code timed Save AS rather than save for web.  A 26MP png image is also quite large the png compression option would also make a difference. If you want the optimal smallest PNG file more time will be required than using the quicker save option. You also need to time all the steps not just the final step. Using Photoshop UI manually Saving is done as a background task the 4 seconded you measured may be a premature event you would need to measure it after the final step Close no save so know for sure the png files has been written. How did you measure it took 4 seconds?