Skip to main content
Participant
November 1, 2023
Question

Cannot read .eps Images in UXP

  • November 1, 2023
  • 4 replies
  • 205 views

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);
});

 

This topic has been closed for replies.

4 replies

Legend
November 2, 2023

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) ;
}) ;
Robert at ID-Tasker
Legend
November 2, 2023

Like @m1b said - for InDesign, EPS is a vector object - not a bitmap.

 

m1b
Community Expert
Community Expert
November 1, 2023

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

Willi Adelberger
Community Expert
Community Expert
November 1, 2023

EPS is an ancient outdated file type. Use PDF/X-4 instead.