Is there a reason why the generated JPG has the ratio of the image frame its in. Say you place a square psd file and make it smaller in the rectangle and also make that frame rectangular. Now the exported jpg will rectangle format instead of the square psd file.

Can this be changed or added in some option, so keep the ratio of the original image?

question is related to this post, but it got deleted (Because of the rules)

This is the original piece of code

var myDoc = app.activeDocument,
apis = myDoc.allPageItems, pageItem, fileName;

while ( pageItem = apis.pop() ) {
  if ( !pageItem.graphics[0].isValid ){ continue;}

  fileName = File ( pageItem.graphics[0].itemLink.filePath ).name;
  fileName = fileName.replace( /\.[a-z]{2,4}$/i, '.jpg' );

  app.jpegExportPreferences.exportResolution = 2400;
  app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.MAXIMUM;

  //give it a unique name
  var myFile = new File ("C:/Users/RANFacistol-Mata/Desktop/Image Trial/"+ fileName);

  pageItem.exportFile(ExportFormat.JPG, myFile);

sorry to say but some of the rules makes the forum possibly overflow with question. A thread can become 10 threads all linked to the same original thread?!

  • Sorry but GDSE is not a "forum". All stack exchange sites follow a strict question and answer format. That's just the way it works here! Also, give your question some time to be answered. I'm not a scripting expert. Hopefully someone may be able to point you in the right direction.
    – Billy Kerr
    Dec 24 '20 at 15:05
  • I’m having a hard time understanding what it is you’re looking for. You say you place a square PSD file, then use its containing frame to clip it to a rectangular shape – and you’re surprised that when you export the image to a JPEG file, that file is rectangular as well; is that right? Remember that you’re exporting the page item, which is a frame. Have you tried exporting the graphic itself (i.e., pageItem.graphics[0].exportFile) instead? I’m not even sure offhand if graphics actually have an exportFile() method available, but if it does, that would seem like the obvious thing to try. Dec 24 '20 at 16:04
  • 2
    If you need the original images, why not merely "package" the indesign file and grab the images from the resulting package folder?? Then, if necessary, batch the images in Photoshop for resizing/recalculating resolution? - point being, if you need the original image, then use the original images, don't export from InDesign.
    – Scott
    Dec 24 '20 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.