Copy link to clipboard
Copied
Hello,
I found a very useful script to save covers as JPEG, with a fixed width, whatever is the original size :
//the export pixel width var targetWidthPixels = 600; var doc = app.activeDocument; with(doc.viewPreferences){ horizontalMeasurementUnits = MeasurementUnits.INCHES; verticalMeasurementUnits = MeasurementUnits.INCHES; } //get the page width in inches var pw=doc.documentPreferences.pageWidth; //calulate the resolution needed to export the jpeg as 1500px wide //if the page is 8.5" x 11", the output pixel dimensions will be 600px x 776px var resout= targetWidthPixels/pw; //the active page var pg=app.activeWindow.activePage.name; //set the res preference and page range with(app.jpegExportPreferences){ exportResolution = resout; pageString = pg; antiAlias = true; embedColorProfile = true; jpegColorSpace = JpegColorSpaceEnum.RGB; //add other properties as needed } //export the JPEG doc.exportFile( ExportFormat.jpg, File(Folder.desktop + "/ExportJPG.jpg"), false );
My question is : how to put this file in a specific folder (/Users/toto/Desktop/TEST MTP/OUT site) with a specific name wich is the 14 first characters of every Indesign file name (9782340-046337_COUV_2022_02_24.indd becomes 9782340-046337.jpg)
Thanks for your Help
You have to modify this part:
File(Folder.desktop + "/ExportJPG.jpg")
"Folder.desktop" would be your "/Users/toto/Desktop/TEST MTP/OUT site"
"/ExportJPG.jpg" would be something like that:
'/' + doc.name.substring(0,13) + '.jpg'
But I'm not JS guy so someone else needs to check and confirm.
File("/Users/toto/Desktop/TEST MTP/OUT site/" + doc.name.substring(0,13) + ".jpg")
I think:
var pg = 3;
should work - or "3".
Copy link to clipboard
Copied
You have to modify this part:
File(Folder.desktop + "/ExportJPG.jpg")
"Folder.desktop" would be your "/Users/toto/Desktop/TEST MTP/OUT site"
"/ExportJPG.jpg" would be something like that:
'/' + doc.name.substring(0,13) + '.jpg'
But I'm not JS guy so someone else needs to check and confirm.
File("/Users/toto/Desktop/TEST MTP/OUT site/" + doc.name.substring(0,13) + ".jpg")
Copy link to clipboard
Copied
Thanks a lot, it works fine.
Can you tell me how to select a specific page in the script.
Probably a change here?:
//the active page var pg=app.activeWindow.activePage.name;
The name of the page is "Print" and the number is 3
Copy link to clipboard
Copied
I think:
var pg = 3;
should work - or "3".
Copy link to clipboard
Copied
Many thanks, it works perfectly! With this script and the app MadeToPrint, I can export in one click:
- 2 versions PDF of the cover with a different spine (with the alternative layout function in Indesign)
- 1 JPEG of the cover plate 1
- 1 JPEG of the cover plate 4
Each file in a different distant folder.
Copy link to clipboard
Copied
Great.
My ID-Tasker is much more versatile. The only slight limitation - can't be used directly on a Mac.
Copy link to clipboard
Copied
I didn't knew this tool but will quickly try it on a PC! Thanks.
Copy link to clipboard
Copied
Thanks.
If you need extra functionality - please let me know.
Copy link to clipboard
Copied
Hello,
Thanks again for your help in january!
The script works fine for MAC OS, but not for PC Windows 10 (I tried it yesterday). Do you have a clue?
Thanks
Copy link to clipboard
Copied
What is the error?
Copy link to clipboard
Copied
Nothing happens…
Copy link to clipboard
Copied
Can you show an example of the paths you are using?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Can you add:
alert("target" + doc.name.substring(0,13) + ".jpg");
before Export JPEG comment ?
Copy link to clipboard
Copied
LIke this?
/set the res preference and page range
with(app.jpegExportPreferences){
exportResolution = resout;
pageString = pg;
antiAlias = true;
embedColorProfile = true;
jpegColorSpace = JpegColorSpaceEnum.RGB;
//add other properties as needed
}
alert("target" + doc.name.substring(0,13) + ".jpg") ;
//export the JPEG
doc.exportFile(
ExportFormat.jpg,
File("target" + doc.name.substring(0,13) + ".jpg"),
false
);
It doesn't work.. (cf screen capture)
Copy link to clipboard
Copied
Yes.
My alert shows wrong path - there is no "\" after "C:" and there is some wrong character after "MARKETING".
The error below - is about something else - 6th line, MeasurementUnits?
Copy link to clipboard
Copied
Looks like ALL "\" has been stripped from the path??
Copy link to clipboard
Copied
OK thanks, I work on it !
Copy link to clipboard
Copied
Yes sorry, it's because it is seen as wrong html and automaticaly corrected by the editor…
Copy link to clipboard
Copied
Yes sorry, it's because it is seen as wrong html and automaticaly corrected by the editor…
By @Stephane27925305ylf8
Not sure what do you mean?
Alert() should display raw text - raw value of the doc.name.substring(0,13) - without any kind of "interpretation"?
And you have "target" text at the beginning - it's not displayed in the alert()?
Copy link to clipboard
Copied
When I try to copy the script text, I have this message (capture)
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I was refering to this screenshot:
Top - "my" alert message - missing ALL "\". So the final path to the file is wrong.
Bottom - you have an error in line 6.
You should use:
to post code here.
Copy link to clipboard
Copied
OK, it looks like the error is about "modal dialog" being open?
Copy link to clipboard
Copied
No, it's just that the script does not launch when I play it on the PC. Just Nothing…