• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Need to save the page by the placed image name

New Here ,
Jul 22, 2021 Jul 22, 2021

Copy link to clipboard

Copied

Hi

I have a bunch of images I need to resize in on indesign, but want to save the images by the image name that is embedded on the page. I've tried some scripts that have left errors and I've tried the sample catalogue script that doesn't do anything at all. Im at a loss please help me.

 

Thank you 

TOPICS
Scripting

Views

428

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advisor , Jul 23, 2021 Jul 23, 2021

hello @defaultgckpsw4387fx \ @Morgan5C5D 

 

The below script will export each page within the Indesign document as a jpeg named by the same origional placed jpeg name. The jpegs are exported to a folder on the desktop named jpgs, you'll need to create the jpgs folder on your desktop before hand. You will also need to set the export settings to your specific needs.

 

 

var aDoc = app.activeDocument;
var docPages = aDoc.pages;

for(p=0;p<docPages.length;p++){

var myPageItems = docPages[p].allPageItems
...

Votes

Translate

Translate
Community Expert ,
Jul 22, 2021 Jul 22, 2021

Copy link to clipboard

Copied

Hi, can you clarify? So you have an Indesign document that has a single placed image, and you want to save-as that indesign document as the name of the placed image? eg. if the placed image is "my image.jpeg", the script should save-as the document as "my image.indd"? Also, where should it save the document?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 23, 2021 Jul 23, 2021

Copy link to clipboard

Copied

Exactly.  ie The name of the image is Purplet-shirt $20.00, it has been sized to a social media size needs to be saved The Purplet-shirt $20.00.

I am resizing catalogue images to social media size, the images are named specifically. I have impoted all of them, now need to save them by the same origional name as jpegs.

Thank you 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 23, 2021 Jul 23, 2021

Copy link to clipboard

Copied

 it has been sized to a social media size needs to be saved The Purplet-shirt $20.00.

 

For social media you must need a specific pixel dimension. Why not batch that in Photoshop?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jul 23, 2021 Jul 23, 2021

Copy link to clipboard

Copied

hello @defaultgckpsw4387fx \ @Morgan5C5D 

 

The below script will export each page within the Indesign document as a jpeg named by the same origional placed jpeg name. The jpegs are exported to a folder on the desktop named jpgs, you'll need to create the jpgs folder on your desktop before hand. You will also need to set the export settings to your specific needs.

 

 

var aDoc = app.activeDocument;
var docPages = aDoc.pages;

for(p=0;p<docPages.length;p++){

var myPageItems = docPages[p].allPageItems
var myPageName = docPages[p].name;

for(i=0;i<myPageItems.length;i++){

//set selection as variable
var thisItem = myPageItems[i];
if(thisItem instanceof Rectangle || thisItem instanceof Polygon || thisItem instanceof Oval){

//get image within the frame
var myLinkedItem = thisItem.pageItems[0];
//get name of the linked image
var myLinkName = myLinkedItem.itemLink.name;

//strip extension from linked image name
var myLinkName = myLinkName.split('.')[0];

app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.maximum; // low medium high maximum
app.jpegExportPreferences.exportResolution = 300;
app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange;
app.jpegExportPreferences.pageString = myPageName;

//Set Name of exported pdf to match the name of the linked image
var myFile = File('~/Desktop/jpgs/' + myLinkName + '.jpg');

//export the JPG
aDoc.exportFile(ExportFormat.JPG, myFile, false);
  }
 }
}

 

 

 

Regards,

Mike

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 23, 2021 Jul 23, 2021

Copy link to clipboard

Copied

Hi Mike, if sizing for social media images is done with InDesign’s Pixel Units, the exportResolution would have to be 72ppi to get a matching exported JPEG pixel dimensions. This image’s parent frame is 500 x 350 pixels, and 72ppi will export it to the same pixel dimensions.

 

Screen Shot.png

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jul 23, 2021 Jul 23, 2021

Copy link to clipboard

Copied

Hello @rob day 

 

Thanks for pointing out the exportResolution would have to be 72ppi...

 

That's why I stated in my post: "You will also need to set the export settings to your specific needs."

 

Regards,

Mike

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 24, 2021 Jul 24, 2021

Copy link to clipboard

Copied

Sorry, I missed that.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 23, 2022 Sep 23, 2022

Copy link to clipboard

Copied

This script worked perfectly for me. I am wondering what I would add to convert the saved images to cmyk.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 23, 2022 Sep 23, 2022

Copy link to clipboard

Copied

 

app.jpegExportPreferences.exportResolution = 300;
app.jpegExportPreferences.jpegColorSpace = JpegColorSpaceEnum.CMYK;
//embeds the document CMYK profile
//app.jpegExportPreferences.embedColorProfile = true;

 

Just keep in mind the output CMYK values of the export depends on the document’s assigned CMYK and RGB profiles, and the appearance of the JPEG will depend on whether the CMYK profile is embedded

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 23, 2022 Sep 23, 2022

Copy link to clipboard

Copied

This is awesomely perfect. Thank you!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 29, 2023 Aug 29, 2023

Copy link to clipboard

Copied

LATEST

Hi Mike. How to change the script to select not all objects on the page, but only the first one and go to the next page?

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines