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
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
...
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?
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
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?
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
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.
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
Copy link to clipboard
Copied
Sorry, I missed that.
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.
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
Copy link to clipboard
Copied
This is awesomely perfect. Thank you!