• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Cannot read .eps Images in UXP

New Here ,
Nov 01, 2023 Nov 01, 2023

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

 

TOPICS
UXP Scripting

Views

115

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 01, 2023 Nov 01, 2023

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 01, 2023 Nov 01, 2023

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 01, 2023 Nov 01, 2023

Copy link to clipboard

Copied

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

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 01, 2023 Nov 01, 2023

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines