Copy link to clipboard
Copied
Hello,
I am trying to load in .eps images and read the image object to perform some operations on a given image using UXP scripts. When I select a .eps image for my placeGun, it is not able to reference the .images.item(0) object. This works for other types of images, such as .tif. It seems UXP scripts does not handle .eps images in the same way as other images. What is the alternative to handling this file type and finding its corresponding image?
const placeGun = doc.placeGuns;
placeGun.loadPlaceGun(file);
const pageItems = placeGun.pageItems.everyItem().getElements();
pageItems.forEach(pageItemInPlaceGun => {
const image = pageItemInPlaceGun.images.item(0);
});
Copy link to clipboard
Copied
EPS is an ancient outdated file type. Use PDF/X-4 instead.
Copy link to clipboard
Copied
Hi @Mahmood956, it is curious how Indesign's DOM objectifies graphics. In this case "images" refer to bitmap images (tif, jpg, gif, etc). Try using "epss". Have a look at the PlaceGun object documentation (it's old ExtendScript, but the DOM is very similar I think).
- Mark
Copy link to clipboard
Copied
Like @m1b said - for InDesign, EPS is a vector object - not a bitmap.
Copy link to clipboard
Copied
For general images that are not limited in type, the graphics collection could be used.
const { app } = require('indesign') ;
const os = require('os') ;
const { localFileSystem } = require('uxp').storage ;
const desktopPath = path.join(os.homedir(), 'Desktop') ;
const targetPathList = [
path.join(desktopPath, '1.eps'),
path.join(desktopPath, '2.eps'),
path.join(desktopPath, '3.ai')
] ;
const targetFiles = await Promise.all(targetPathList.map((pathText) => {
return localFileSystem.getEntryWithUrl(pathText) ;
})) ;
const doc = app.activeDocument ;
const placeGun = doc.placeGuns ;
placeGun.loadPlaceGun(targetFiles) ;
const graphics = placeGun.graphics.everyItem().getElements() ;
graphics.forEach((graphic) => {
console.log(graphic) ;
}) ;