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

Need to save the page by the placed image name

New Here ,
Jul 22, 2021 Jul 22, 2021

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
813
Translate
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
...
Translate
Community Expert ,
Jul 22, 2021 Jul 22, 2021

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?

Translate
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

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 

 

 

Translate
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

 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?

Translate
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

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

Translate
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

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

 

Translate
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

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

Translate
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

Sorry, I missed that.

Translate
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

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

 

Translate
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

 

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

Translate
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

This is awesomely perfect. Thank you!

Translate
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
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?

 

Translate
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