3 Replies Latest reply on Mar 25, 2016 2:38 AM by karthiks94217840

    Export to JPG multiple times with different resolution

    KlausFriese Level 1

      Hi everybody,

       

      I want to export my document to jpg files in different resolutions - a preview and a thumbnail image. I'm using this code I found here in the forum for export:


      function exportPages( _dpi , _destFilename ) {

          try {

              app.jpegExportPreferences.exportResolution = _dpi;

              app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.LOW;

          

              app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.EXPORT_ALL;

              app.scriptPreferences.version = "7.0"

              app.jpegExportPreferences.jpegColorSpace = JpegColorSpaceEnum.RGB;

              app.scriptPreferences.version = "6.0"

              app.activeDocument.sections.everyItem().includeSectionPrefix = false;

              var f = File ( _destFilename );

              app.activeDocument.exportFile( ExportFormat.jpg, f );

          } catch( err ) {

              alert( err.message );

          }

      }


      and I'm calling


      exportPages( 96 , "~/jdExport.jpg" );

      exportPages( 30 , "~/jdExportThumbnail.jpg" );


      This should create images with 96dpi and 30dpi. But after the first call the app.jpegExportPreferences.exportResolution is undefined. I can swap the function calls - first one works, second fails.


      Any idea why I can't export twice?


      Thanks

      Klaus