Skip navigation
Currently Being Moderated

Batch export grouped items as jpeg?

Feb 21, 2012 7:32 AM

Hi there-

 

We have decided that it's time to switch to InDesign; we're paying for it as part of CS4 anyway (we will be upgrading when the next update is announced), and Quark just isn't doing what we need anymore. We're trying to take care of a few things before just jumping in, and I've found an issue with one of our tasks.

 

Our files are made up of anywhere from 5-15 individual ads, which are printed in a strip. Each of those individual ads needs to be exported as a jpeg so that it can be placed on our company's website. In Quark, we would run Gluon's XPress Image Pro, and it would find each grouped object and export it, but Gluon does not offer an ID version of this software. I was hoping that there would be some nifty little built-in trick that would do this for me, but the general forum seemed to think otherwise. Bob Levine suggested I pop over here and see if I could find a scripting solution. I'm pretty new to scripting, but if you've got any advice, I'm all ears.

 

Thanks!

 
Replies
  • Currently Being Moderated
    Feb 21, 2012 11:14 AM   in reply to tlcano

    As I said in that thread that script may help you with this… I feel I should help… This should give you a starter… It will just dump the JPEGS on your desktop for now…

     

     

    #target indesign
     
    function groupsToJPEGs() {
      
              if ( app.documents.length == 0 ) { return; }
      
              var i, doc, grps, prfs, expFile;
     
              doc = app.activeDocument;
      
              prfs = app.jpegExportPreferences;
     
              prfs.antiAlias = true;
              prfs.embedColorProfile = true;
              prfs.exportResolution = 300;
              prfs.jpegColorSpace = JpegColorSpaceEnum.RGB;
              prfs.jpegQuality = JPEGOptionsQuality.MAXIMUM;
              prfs.simulateOverprint = true;
      
              grps = doc.groups;
     
              for ( i = 0; i < grps.length; i++ ) {
     
                        expFile = File( Folder.desktop + '/Ad_Group_' + i + '.jpg' );
     
                        doc.groups[i].exportFile( ExportFormat.JPG, expFile, false );
     
              };
     
    };
     
    groupsToJPEGs();
     
    
     
    |
    Mark as:
  • Currently Being Moderated
    Feb 29, 2012 1:58 PM   in reply to tlcano

    Exact line number and error message?

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 1, 2012 5:02 AM   in reply to tlcano

    Hum, how did you go about saving it? I just C&P the above into a new ESTK window and alt+comm+k it say it OK… comm+r and ooops… I've got the wrong doc open now ( who's the muppet )… A trip to the trash for that lot…

     

    Screen shot 2012-03-01 at 12.59.26.png

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 17, 2012 12:02 PM   in reply to tlcano

    If your boss is not wanting to pay for the switch to ID ( based on this snippet ) Then he/she is a bigger muppet than me… ( dam and blast there goes my commission ) I've C&P back to the toolkit twice now and it works?

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 17, 2012 12:56 PM   in reply to tlcano

    CS4 its different set of properties for the export… You may not get all the options you want in that version of ID but it shold only take a moment to make something work…

    I don't have CS4 so I can't test this… The options are limited… Now there's a reason for an upgrade commi$$ion back on…

     

    #target indesign
     
    function groupsToJPEGs() {
      
              if ( app.documents.length == 0 ) { return; }
      
              var i, doc, grps, prfs, expFile;
     
              doc = app.activeDocument;
      
              prfs = app.jpegExportPreferences;
     
              prfs.resolution = 300;
              prfs.jpegQuality = JPEGOptionsQuality.MAXIMUM;
              prfs.jpegRenderingStyle = JPEGOptionsFormat.BASELINE_ENCODING;
      
              grps = doc.groups;
     
              for ( i = 0; i < grps.length; i++ ) {
     
                        expFile = File( Folder.desktop + '/Ad_Group_' + i + '.jpg' );
     
                        doc.groups[i].exportFile( ExportFormat.JPG, expFile, false );
     
              };
     
    };
     
    groupsToJPEGs();
     
    
     
    |
    Mark as:
  • Currently Being Moderated
    Apr 18, 2012 9:24 AM   in reply to tlcano

    Yes, yes, yes script can be set up ( fine tuned ) to do all sorts of things and much more so in ID over Quark… My fault I didn't read the your post properly ( hey your the first person to be behind me on the upgrade trail  ). I just presumed CS5 or greater… 3 years I nagged for upgrades ( and I can grumble with the best  )

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 19, 2012 1:55 AM   in reply to tlcano

    expFile = File( Folder.desktop/Batch + '/filename' + i + '.jpg' );

     

    Your notation for getting the Folder is not correct.

     

    Folder.desktop is a valid object, and it returns a Folder object (which can be treated as a regular text string). You cannot just paste "/Batch" right after it -- that's Bad Syntax. You also add your variable 'filename' as a literal string -- between quotes. That only adds the exact string "filename" (uh, but then without those quotes) to the path.

     

    Try this:

     

    expFile = File( Folder.desktop+ '/Batch/' + filename + i + '.jpg' );

     

    -- it will build up the file name out of the individual parts "Desktop Folder Path", "The Literal String 'Batch'", "the value of the variable filename", "the value of 'i'", and, closing down, "the literal string 'dot jpg'".

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 19, 2012 7:31 AM   in reply to tlcano

    Try this it works with my CS5 and should cover your CS4 too… A bit long winded… Of cause you may need to pop back here for CS6 where things may or may not chane again…

    #target indesign
     
    function groupsToJPEGs() {
      
        if ( app.documents.length == 0 ) { return; }
      
        var i, doc, grps, prfs, expFile, saveFold;
        
        saveFold = Folder( Folder.desktop + '/Batch' );
        
        if ( ! saveFold.exists ) { saveFold.create(); }
     
        doc = app.activeDocument;
      
        prfs = app.jpegExportPreferences;
        
        if ( parseInt( app.version ) == 7 ) {
     
            prfs.antiAlias = true;
            prfs.embedColorProfile = true;
            prfs.exportResolution = 300;
            prfs.jpegColorSpace = JpegColorSpaceEnum.RGB;
            prfs.jpegQuality = JPEGOptionsQuality.MAXIMUM;
            prfs.simulateOverprint = true;
        
        };
     
        if ( parseInt( app.version ) == 6 ) {
     
              prfs.resolution = 200;
              prfs.jpegQuality = JPEGOptionsQuality.MAXIMUM;
              prfs.jpegRenderingStyle = JPEGOptionsFormat.BASELINE_ENCODING;
        
        };
      
        grps = doc.groups;
     
        for ( i = 0; i < grps.length; i++ ) {
     
            expFile = File( saveFold + '/'+ doc.name + '_' + i + '.jpg' );
     
            doc.groups[i].exportFile( ExportFormat.JPG, expFile, false );
     
        };
     
    };
     
    groupsToJPEGs();
    
     
    |
    Mark as:
  • Currently Being Moderated
    Apr 19, 2012 8:29 AM   in reply to tlcano

    What does this tell you…?

     

    alert( app.activeDocument.groups.length )
    

     

     

    expFile = File( saveFold + '/'+ doc.name + '_' + ( i + 1 ) + '.jpg' );
    

     

    Should sort the zero base i

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 19, 2012 8:46 AM   in reply to tlcano

    Just run the TOP snippet as it is a one line script…

     

    The second snippet is a replacemnet line… See the ( i + 1 ) has been added in…

     

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 18, 2012 10:32 PM   in reply to tlcano

    Hi,

     

    The same way as we export selection to jpeg, is it possible to convert the selection to swf? Please help.

     

    Thanks,

    Vanitha Allwin

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 19, 2012 1:50 AM   in reply to tlcano

    Here it is modified to export all opened documents. Don't have CS6 yet, but it shoud work.

    #target indesign
    var saveFold;  
      function main(){    
         saveFold = Folder( Folder.desktop + '/Batch' );
            if ( ! saveFold.exists ) { saveFold.create(); }
        var prfs;
     
        prfs = app.jpegExportPreferences;
     
        if ( parseInt( app.version ) >= 7 ) {
     
            prfs.antiAlias = true;
            prfs.embedColorProfile = true;
            prfs.exportResolution = 300;
            prfs.jpegColorSpace = JpegColorSpaceEnum.RGB;
            prfs.jpegQuality = JPEGOptionsQuality.MAXIMUM;
            prfs.simulateOverprint = true;
     
        };
     
        if ( parseInt( app.version ) == 6 ) {
     
              prfs.resolution = 200;
              prfs.jpegQuality = JPEGOptionsQuality.MAXIMUM;
              prfs.jpegRenderingStyle = JPEGOptionsFormat.BASELINE_ENCODING;
     
        };
       for (var j=0; j<app.documents.length;j++){
    groupsToJPEGs (app.documents[j]);
    }
    }
    function groupsToJPEGs(doc) {
          var i, grps, expFile;
     
     
        grps = doc.groups;
     
        for ( i = 0; i < grps.length; i++ ) {
     
            expFile = File( saveFold + '/'+ doc.name + '_' + ( i + 1 ) + '.jpg' ); 
            doc.groups[i].exportFile( ExportFormat.JPG, expFile, false );
     
        };
     
    };
     
    main();
    
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 19, 2012 1:58 AM   in reply to VanithaAllwin


    VanithaAllwin wrote:

     

    Hi,

     

    The same way as we export selection to jpeg, is it possible to convert the selection to swf? Please help.

     

    Thanks,

    Vanitha Allwin

    Tell me the preferences you need for wxporting the swf, and i hope i can help.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 19, 2012 2:03 AM   in reply to Vamitul

       The swf preferences are given below except swf with and height. The swf width and height should match the selection.

     

         app.swfExportPreferences.fitMethod  = FitMethodSettings.fitGivenScalePercentage;

        app.swfExportPreferences.fitOption = FitDimension.fit1024x768;

        app.swfExportPreferences.fitScale = 100;

        app.swfExportPreferences.pageRange = range;

        app.swfExportPreferences.dynamicDocumentExportReaderSpreads = 0;

        app.swfExportPreferences.rasterizePages = false;

        app.swfExportPreferences.generateHTML = false;

        app.swfExportPreferences.viewSWFAfterExporting = false;

        app.swfExportPreferences.textExportPolicy = DynamicDocumentsTextExportPolicy.live;

        app.swfExportPreferences.includeInteractivePageCurl = true;

        app.swfExportPreferences.rasterCompression = RasterCompressionOptions.losslessCompression;

        app.swfExportPreferences.jpegQualityOptions = DynamicDocumentsJPEGQualityOptions.maximum;

        app.swfExportPreferences.curveQuality = SWFCurveQualityValue.maximum;

        app.swfExportPreferences.rasterResolution = 100;

     

    Thanks,

    Vanitha Allwin

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 19, 2012 3:06 AM   in reply to VanithaAllwin

    then replace the line:

        prfs = app.jpegExportPreferences;

    with

        prfs = app.swfExportPreferences;

     

    and

              prfs.antiAlias = true;
            prfs.embedColorProfile = true;
            prfs.exportResolution = 300;
            prfs.jpegColorSpace = JpegColorSpaceEnum.RGB;
            prfs.jpegQuality = JPEGOptionsQuality.MAXIMUM;
            prfs.simulateOverprint = true;
    with your preferences.

    should work.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 19, 2012 11:05 PM   in reply to Vamitul

    The above setting shows error saying "preferences doesn't have antiAlias property". Eventhough i have used correct swf preferences setting, the whole page has been exported as swf instead of only the selection. Please help. I need this urgently.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 19, 2012 11:32 PM   in reply to VanithaAllwin

    Hello.

     

    here is the full script. I made a few changes. Hope it works for you.

     

    #target indesign
    var saveFold;  
      function main(){    
         saveFold = Folder( Folder.desktop + '/Batch' );
            if ( ! saveFold.exists ) { saveFold.create(); }
     
       app.documents[0].groups.firstItem().select();
     
      //  app.swfExportPreferences.fitMethod  = FitMethodSettings.fitGivenScalePercentage;
    //    app.swfExportPreferences.fitOption = FitDimension.fit1024x768;
        app.swfExportPreferences.fitScale = 100;
      //  app.swfExportPreferences.pageRange = "Selection";
        app.swfExportPreferences.dynamicDocumentExportReaderSpreads = 0;
        app.swfExportPreferences.rasterizePages = false;
        app.swfExportPreferences.generateHTML = false;
        app.swfExportPreferences.viewSWFAfterExporting = false;
        app.swfExportPreferences.textExportPolicy = DynamicDocumentsTextExportPolicy.live;
        //app.swfExportPreferences.includeInteractivePageCurl = true;
        app.swfExportPreferences.rasterCompression = RasterCompressionOptions.losslessCompression;
        app.swfExportPreferences.jpegQualityOptions = DynamicDocumentsJPEGQualityOptions.maximum;
        app.swfExportPreferences.curveQuality = SWFCurveQualityValue.maximum;
        app.swfExportPreferences.rasterResolution = 100; 
     
     for (var j=0; j<app.documents.length;j++){
    groupsToJPEGs (app.documents[j]);
    }
    }
    function groupsToJPEGs(doc) {
          var i, grps, expFile;
     
     
        grps = doc.groups;
     
        for ( i = 0; i < grps.length; i++ ) {
     
            expFile = File( saveFold + '/'+ doc.name + '_' + ( i + 1 ) + '.swf' ); 
            doc.groups[i].select();
            doc.groups[i].exportFile( ExportFormat.SWF, expFile, false );
     
        };
     
    };
     
    main();
    

     

     

    ps. Anyone can tell me how can i make the "advanced editor" as default for replies in this forum?

     

    Message was edited by: Vamitul

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 19, 2012 11:42 PM   in reply to Vamitul

    ps. Anyone can tell me how can i make the "advanced editor" as default for replies in this forum?

     

    @Vatimul – as the following screen grab shows, "Use advanced editor" is back when replying (above the upper right corner of the edit field):

     

    Bildschirmfoto 2012-06-20 um 08.38.07.png

     

    If you cannot see it, maybe you could refresh the webpage with cmd + shift + r in the browser. Maybe it's your browser. I'm using Firefox on Mac OSX 10.6.8.

     

    Uwe

     

    Message was edited by: Laubender

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 19, 2012 11:58 PM   in reply to VanithaAllwin

    I changed the setting as you mentioned. The whole page has been exported as swf instead of only the selection.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 20, 2012 12:01 AM   in reply to VanithaAllwin

    did you use the script i just posted above?

    you might need to manualy export one group before running the scrip.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2012 12:41 AM   in reply to Vamitul

    Yes. It doesn't seem to be working.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 17, 2013 8:35 AM   in reply to tlcano

    Does this process work with nested groups (groups that contain other groups)?

     

    How do you locate the outermost group?

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points