20 Replies Latest reply on Jul 26, 2011 5:44 AM by John Hawkinson

    JPG export preset in InDesign?

    Tricia Ho Level 1

      Hi all,

       

      Is there a way to save my JPG export selections as a preset? I have to export JPGs of the same document for two different purposes and they have different export requirements. Is there a way to save my selections as a preset the same way I can save my PDF export selections as presets?

       

      InDesign 7.0.4

      Mac 10.6.8

       

      Cheers,

      Trish

        • 1. Re: JPG export preset in InDesign?
          Stix Hart Level 5

          Sorry, no there isn't.  However I'm sure (hint, hint, nudge, nudge) that someone could write a script that would be user editable.  I'd find it quite useful myself.

          1 person found this helpful
          • 2. Re: JPG export preset in InDesign?
            Tricia Ho Level 1

            Thanks for that, I feared that might be the case.

             

            And yes, a script would be very handy indeed!!

            • 3. Re: JPG export preset in InDesign?
              John Hawkinson Level 5

              Sorry, no there isn't.  However I'm sure (hint, hint, nudge, nudge) that someone could write a script that would be user editable.

              I dunno, Stix, maybe it's a good time for you (hint,hint,nudge,nudge) to learn to write scripts? This one should be pretty easy! We'll help!

              • 4. Re: JPG export preset in InDesign?
                Stix Hart Level 5

                OK John, I'll bite!  I modify them all the time and have made a few simple ones for my own use before...

                 

                So how would I go about the first step?  I have the CS5 scripting guide which has a sample script for PDF and EPS in it but how would I create a jpeg one?

                • 5. Re: JPG export preset in InDesign?
                  John Hawkinson Level 5

                  OK, let's start with the EPS export on p.48ff, because it's probably more like the JPEG export.

                  It's exporting a document, so you want to pull out Jongware's handy HTML version of the scripting DOM, and look at the document export method:

                  Document.exportFile.

                   

                  And of course, you just change the ExportFormat. You can click the link in Jongware's HTML to see the different formats.

                  You'll also want to set up the jpegExportPreferences instead of the EPS ones...

                   

                  Where's the first spot you get stuck?

                  • 6. Re: JPG export preset in InDesign?
                    Stix Hart Level 5

                    I had Jongware's CHM file already but never used it much.  The first spot I get stuck in is this line:

                     

                    app.activeDocument.exportFile(ExportFormat.epsType, myFile, false);

                     

                    Where do I find what to change epsType to?

                    • 7. Re: JPG export preset in InDesign?
                      Stix Hart Level 5

                      Whoops, found it now, it should be ExportFormat.jpg (I'd tried jpeg already!).

                       

                      OK I'm on my way for the moment...  This is fun! 

                      • 8. Re: JPG export preset in InDesign?
                        John Hawkinson Level 5

                        Did you follow the link I gave you? You should have been able to click on the word ExportFormat and see all the possible types, including ExportFormat.JPG.

                        • 9. Re: JPG export preset in InDesign?
                          Stix Hart Level 5

                          Yeah but I couldn't find the link to Export formats the first time I looked.  Thanks for that, I now have a completed script!  I hope this is the right way to post it:

                           

                          //Display a "choose folder" dialog box.
                          if(app.documents.length != 0){
                          var myFolder = Folder.selectDialog ("Choose a Folder");
                          if(myFolder != null){
                          myExportPages(myFolder);
                          }
                          }
                          else{
                          alert("Please open a document and try again.");
                          }
                          function myExportPages(myFolder){
                          var myFilePath, myPageName, myFile;
                          var myDocument = app.activeDocument;
                          var myDocumentName = myDocument.name;
                          var myDialog = app.dialogs.add({name:"ExportPages"});
                          with(myDialog.dialogColumns.add().dialogRows.add()){
                          staticTexts.add({staticLabel:"Base name:"});
                          var myBaseNameField = textEditboxes.add({editContents:myDocumentName,
                          minWidth:160});
                          }
                          var myResult = myDialog.show();
                          if(myResult == true){
                          //The name of the exported files will be the base name +
                          //the page name + ".jpeg".
                          var myBaseName = myBaseNameField.editContents;
                          //Remove the dialog box from memory.
                          myDialog.destroy();
                          //Generate a file path from the folder name, the base document name,
                          //page name.
                          for(var myCounter = 0; myCounter < myDocument.pages.length;
                          myCounter++){
                          myPageName = myDocument.pages.item(myCounter).name;
                          //Modify the following to change the Resolution. Enter a figure instead of 300
                          app.jpegExportPreferences.exportResolution = 300;
                          //Modify the following to change the colour space. the options are:
                          //JpegColorSpaceEnum.RGB
                          //JpegColorSpaceEnum.CMYK
                          //JpegColorSpaceEnum.GRAY
                          app.jpegExportPreferences.jpegColorSpace = JpegColorSpaceEnum.CMYK;
                          //Modify the following to change the jpeg quality. the options are:
                          //JPEGOptionsQuality.LOW
                          //JPEGOptionsQuality.MEDIUM
                          //JPEGOptionsQuality.HIGH
                          //JPEGOptionsQuality.MAXIMUM
                          app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.MAXIMUM;
                          //Modify the following to change the Rendering Style. the options are:
                          //JPEGOptionsFormat.BASELINE_ENCODING
                          //JPEGOptionsFormat.PROGRESSIVE_ENCODING
                          app.jpegExportPreferences.jpegRenderingStyle = JPEGOptionsFormat.BASELINE_ENCODING;
                          //The name of the exported files will be the base name +
                          //the page name + ".jpeg".
                          //If the page name contains a colon (as it will if the
                          //document contains sections),
                          //then remove the colon.
                          var myRegExp = new RegExp(":","gi");
                          myPageName = myPageName.replace(myRegExp, "_");
                          myFilePath = myFolder + "/" + myBaseName + "_" + myPageName + ".jpeg";
                          myFile = new File(myFilePath);
                          app.activeDocument.exportFile(ExportFormat.jpg, myFile, false);
                          }
                          }
                          else{
                          myDialog.destroy();
                          }
                          }
                          

                           

                          To the OP, I assume you know what to do with the above?  You can modify it to suit.

                          • 10. Re: JPG export preset in InDesign?
                            Stix Hart Level 5

                            @ John, P.S.  all I did was modify a script though, I didn't "write" it.

                            • 11. Re: JPG export preset in InDesign?
                              John Hawkinson Level 5

                              Wow, you put a user interface on it!

                              Nice job.

                              (looks like your indentation didn't quite work for some reason, but oh well)

                               

                              Yeah, yeah, there's no need to write stuff. There's a wealth of information out there...

                              • 12. Re: JPG export preset in InDesign?
                                Tricia Ho Level 1

                                Thanks so much for this! Just gave it a try and it didn't work for me, got

                                an error message:

                                 

                                "Failed to export the JPEG File: Invalid page number specified".

                                 

                                I'm certain it's something I did wrong, help?

                                • 13. Re: JPG export preset in InDesign?
                                  Stix Hart Level 5

                                  I'm pretty sure it won't be your fault, but I don't seem to be able to fix it. Try this one but it exports the number of pages squared!  For example a 4 page document gives you 16 jpegs, 5 = 25 and so on.

                                   

                                  What am I doing wrong John?  I added in this line: app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.EXPORT_ALL;

                                   

                                  //Display a "choose folder" dialog box.
                                  if(app.documents.length != 0){
                                  var myFolder = Folder.selectDialog ("Choose a Folder");
                                  if(myFolder != null){
                                  myExportPages(myFolder);
                                  }
                                  }
                                  else{
                                  alert("Please open a document and try again.");
                                  }
                                  function myExportPages(myFolder){
                                  var myFilePath, myPageName, myFile;
                                  var myDocument = app.activeDocument;
                                  var myDocumentName = myDocument.name;
                                  var myDialog = app.dialogs.add({name:"ExportPages"});
                                  with(myDialog.dialogColumns.add().dialogRows.add()){
                                  staticTexts.add({staticLabel:"Base name:"});
                                  var myBaseNameField = textEditboxes.add({editContents:myDocumentName,
                                  minWidth:160});
                                  }
                                  var myResult = myDialog.show();
                                  if(myResult == true){
                                  //The name of the exported files will be the base name +
                                  //the page name + ".jpeg".
                                  var myBaseName = myBaseNameField.editContents;
                                  //Remove the dialog box from memory.
                                  myDialog.destroy();
                                  //Generate a file path from the folder name, the base document name,
                                  //page name.
                                  for(var myCounter = 0; myCounter < myDocument.pages.length;
                                  myCounter++){
                                  myPageName = myDocument.pages.item(myCounter).name;
                                  app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.EXPORT_ALL;
                                  //Modify the following to change the Resolution. Enter a figure instead of 300
                                  app.jpegExportPreferences.exportResolution = 300;
                                  //Modify the following to change the colour space. the options are:
                                  //JpegColorSpaceEnum.RGB
                                  //JpegColorSpaceEnum.CMYK
                                  //JpegColorSpaceEnum.GRAY
                                  app.jpegExportPreferences.jpegColorSpace = JpegColorSpaceEnum.CMYK;
                                  //Modify the following to change the jpeg quality. the options are:
                                  //JPEGOptionsQuality.LOW
                                  //JPEGOptionsQuality.MEDIUM
                                  //JPEGOptionsQuality.HIGH
                                  //JPEGOptionsQuality.MAXIMUM
                                  app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.MAXIMUM;
                                  //Modify the following to change the Rendering Style. the options are:
                                  //JPEGOptionsFormat.BASELINE_ENCODING
                                  //JPEGOptionsFormat.PROGRESSIVE_ENCODING
                                  app.jpegExportPreferences.jpegRenderingStyle = JPEGOptionsFormat.BASELINE_ENCODING;
                                  //The name of the exported files will be the base name +
                                  //the page name + ".jpeg".
                                  //If the page name contains a colon (as it will if the
                                  //document contains sections),
                                  //then remove the colon.
                                  var myRegExp = new RegExp(":","gi");
                                  myPageName = myPageName.replace(myRegExp, "_");
                                  myFilePath = myFolder + "/" + myBaseName + "_" + myPageName + ".jpeg";
                                  myFile = new File(myFilePath);
                                  app.activeDocument.exportFile(ExportFormat.jpg, myFile, false);
                                  }
                                  }
                                  else{
                                  myDialog.destroy();
                                  }
                                  }
                                  
                                  • 14. Re: JPG export preset in InDesign?
                                    Tricia Ho Level 1

                                    I'm not sure if this helps (or not) but I tested the script on a document

                                    with only 1 page.

                                    • 15. Re: JPG export preset in InDesign?
                                      John Hawkinson Level 5

                                      Well, now you see the danger of making it complicated.

                                      I would have stuck with the simple version at the bottom of p.48. It's a little hard, looking at that script, to know what it has set everything to as a result of your dialogs. (Oh, I see, you took the script from p.49...)

                                       

                                      Anyhow, it looks like you don't ever set app.jpegExportPreferences.pageString, so I'm not sure how it knows what pages to export each time around the loop. Depending on how that property defaults, it could also be the source of Tricia's problem.

                                       

                                      If you set EXPORT_ALL, then it is going to export all pages of your document each time through the loop, and you go through the loop once per page. Hence your squaring. So you can either eliminate the loop or eliminate the EXPORT_ALL.

                                       

                                      I'm not sure why the EPS export uses .pageRange and the JPEG export uses .pageString. Life's little differences...

                                      • 16. Re: JPG export preset in InDesign?
                                        mckayk_777 Level 2

                                        G'day Trish,

                                         

                                        Not sure if this will help as there are not many options when exporting to jpg.

                                         

                                        But there is a script called "PageExporterUtility5.0.1.jsx"

                                         

                                        This script has an option to export to EPS PDF & JPG but when you use it you only have the options to change Quality & Encoding Type

                                        • 17. Re: JPG export preset in InDesign?
                                          Tricia Ho Level 1

                                          I've got a feeling that I've stuffed up somewhere ...

                                           

                                          Here's what I've done:

                                          1. Copy and paste into text editor.

                                          2. Save file as .js in Applications > Adobe InDesign > Scripts > Scripts

                                          Panel > Samples > exporttojpg (I created this folder)

                                          3. Open an InDesign document

                                          4. Double click on the exporttojpg.js in the Scripts palette.

                                          5. Select Desktop

                                          6. Leave as is in ExportPages dialogue box, click OK

                                          7. The new script works perfectly for the one-pager but creates duplicates

                                          if there are multiple pages in the document.

                                           

                                          Am I missing anything?

                                          • 18. Re: JPG export preset in InDesign?
                                            Tricia Ho Level 1

                                            Thanks for that! Unfortunately I don't have the budget to spend $99 on a

                                            script. Would be nice if I did.

                                            • 19. Re: JPG export preset in InDesign?
                                              Stix Hart Level 5

                                              What you're doing is fine, there is a problem in the script that is doing that, like John says it's looping, I don't know how to fix it though!  Someone else is bound to, otherwise I'll try making it simpler tomorrow (my time).

                                              • 20. Re: JPG export preset in InDesign?
                                                John Hawkinson Level 5

                                                What you're doing is fine, there is a problem in the script that is doing that, like John says it's looping, I don't know how to fix it though!

                                                Wait, what? You're saying you don't understand why it is looping?

                                                 

                                                It is looping because it is designed to loop. Right here:

                                                 

                                                for(var myCounter = 0; myCounter < myDocument.pages.length;
                                                myCounter++){

                                                (you really should fix the indentation).

                                                 

                                                Everything in those {braces} is executed once per page!

                                                That's why I said:

                                                 

                                                If you set EXPORT_ALL, then it is going to export all pages of your document each time through the loop, and you go through the loop once per page. Hence your squaring. So you can either eliminate the loop or eliminate the EXPORT_ALL.

                                                 

                                                So I would think you should be all set! No?