Export page with linked image name
Learn / Forums / General InDesign Topics / Export page with linked image name
- This topic has 5 replies, 3 voices, and was last updated 4 years, 2 months ago by Jeremy Howard.
-
AuthorPosts
-
-
January 27, 2020 at 9:57 am #1225368Brent WoudaParticipant
Hello,
I have an Indesign file that has one image on every page (I used a script “image to csv”).
I would like to export each page as an png.Now here is the thing: I want to have each page be named after the image that is linked on the page.
backgroud information
I know some people use photoshop to make a batch to resize images. Thing is that from time to time I need to overrule and adjust the landscape / portrait images into square images. Therefore I use indesign to make an image fit, resize etc I even have a set of pre-made arrows and lines to add some extra here and there on top of the image. That is why I choose indesign, to run the csv, data merge and the next automation is save each page as a new image that has the original image name…Hope someone can provide a script or different automation work around to save me loads of time .
Thanks in advance
Brent
ps. am using indesign cc 2020
-
January 27, 2020 at 6:34 pm #14323189Jeremy HowardParticipant
Give this a shot:
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(“/Users/admin/Desktop/” + myLinkName + “.jpg”);//export the pdf
aDoc.exportFile(ExportFormat.JPG, myFile, false);
}
}
} -
January 28, 2020 at 12:16 am #14323188Brent WoudaParticipant
Thanks for you reply.
I get a javascript error.Is it possible to fix it (mistake nr 8 on line 21)
And is it possible to export a png (72 dpi) /Thanks in advance
-
January 28, 2020 at 1:31 am #14323187Brent WoudaParticipant
Thanks for you reply.
I get a javascript error.Is it possible to fix it (mistake nr 8 on line 21)
And is it possible to export a png (72 dpi) /Thanks in advance
-
January 28, 2020 at 5:11 am #14323185Vinny –Member
This is a WordPress thing.
Try changing the pasted quotes into straight quotes.
Also, change them on the line defining “var myFile = …” (that you also might have to change, according to your OS and/or your desired destination) -
January 28, 2020 at 8:56 am #14323183Brent WoudaParticipant
Thanks
Solved the quotes issue.But…
It seems it actually looks for the original image on the desktop or the file destination i provide.
Then it cannot find it.
https://paste.pics/7V9FSthe original files are in a google drive. the export can go wherever I want but so far no export.
By the way: I changed into: var myFile = File(“/C:/scriptindesign/” + myLinkName + “.jpg”);
-
-
AuthorPosts
- You must be logged in to reply to this topic.