Exporting embedded images from InDesign
[Apologies for cross-posting. I mistakenly posted in the InDesign SDK earlier, where it didn't get a lot of views or helpful responses. I couldn't find a way to move the post.]
I am looking for a way to programatically export embedded images from InDesign documents. These images are not linked files are a placed image would normally be. Instead, they seem to be completely embedded within the InDesign file; exporting as IDML causes the raw image data to be exported within XML itself. The itemLink property is null for the Image object.
Searching in the scripting reference leads to the Image.exportForWeb and Image.exportFile methods. However, when I tried the exportForWeb function, it failed silently and returned null.
The exportFile method worked but it takes as input the export format. Since the format of the original image is not available within the script, using exportFile will entail a potentially lossy conversion. (Checking for the imageTypeName for the Image object throws a "The property is not applicable in the current state" error.) Also, the exported file generated with exportFile seems to be limited to 20kb regardless of how large the original image is.
One suggestion on the old post was to try Link.unembed. However, the Image.itemLink property is itself null so unembedding doesn't seem to be possible that way.
Is there a better way to go about exporting these images? Any ideas why exportForWeb won't work. Thank you.
