Copy link to clipboard
Copied
I'm looking for a way, possibly via a script, to export all selected objects on an InDesign page as individual separate PNG files.
The linked method via html export doesn't work for my objects that are text within a rectangle frame (for png buttons). The html export treats that as text and not an image. Is there a script or other way of exporting all selected objects to png files? I'd like to keep the text live if possible. Thanks!
Exporting all selected objects as individual separate png files
Are you aware that PNG is a bitmap format? This
https://forums.adobe.com/people/Dan+Niemi wrote
I'd like to keep the text live if possible ...
ain't gonna happen. Apart from that, this seems to suffice:
for (s=0; s<app.selection.length; s++)
app.selection
.exportFile(ExportFormat.PNG_FORMAT, File(new File(Folder.myDocuments+"/image_"+s+".png")));
Result: the top 3 selected objects -- a text frame, a group, and a standalone image -- get exported to 3 images:
Copy link to clipboard
Copied
Outline the text so they become essentially static objects and not font-based text.
Copy link to clipboard
Copied
Are you aware that PNG is a bitmap format? This
https://forums.adobe.com/people/Dan+Niemi wrote
I'd like to keep the text live if possible ...
ain't gonna happen. Apart from that, this seems to suffice:
for (s=0; s<app.selection.length; s++)
app.selection
.exportFile(ExportFormat.PNG_FORMAT, File(new File(Folder.myDocuments+"/image_"+s+".png")));
Result: the top 3 selected objects -- a text frame, a group, and a standalone image -- get exported to 3 images:
Copy link to clipboard
Copied
This is perfect, thank you!
Yup, I'm aware png is bitmap, I just needed to keep it live in the actual indesign document. (not outlining)
Copy link to clipboard
Copied
Ah, you meant the other way around! No worries there, this export does not change a thing in the original file.
This PNG export uses a default value for dpi; I did not look it up but I think later versions of InDesign allow you to use custom values. So if you find you need larger images, say the word and someone might know where to find it.
Copy link to clipboard
Copied
Thanks again! Your scripting assistance to others has helped me countless times as I'm learning.
this line works for me for resolution:
app.pngExportPreferences.exportResolution = 72;
My only issue that I see is that the exported size doesn't match the size of the object. For example, this object below is 100x40, but the exported png for the 2 objects is 100x44 and 100x42, respectively. Is there something that would cause this discrepancy (2 lines of text vs 1 is the only difference between the 2)
If this is a separate issue, feel free to close and I can ask on a separate thread.
Copy link to clipboard
Copied
InDesign is a horrible application to use pixels in. It's just not what it was designed for. It can work highly accurately in points, millimeters, and imperial inches, with a mind boggling accuracy (near to the wavelength of visible light!) ... but the "pixel" is not a real world unit. If it were, you could have your length on your driver's license in pixels.
In your case I'd sooner believe that the size of the exported PNG images is "more correct" than what InDesign itself thinks it is, but of course it is not so simple. Then again, I've never willingly used InDesign to create PNG files with, so I am at a loss here. (I'd prefer Photoshop -- or even Illustrator! -- over InDesign, for any pixel related work.)