Copy link to clipboard
Copied
I am trying to write a script to open an EPS file in Photoshop if it is a raster image and in Illustrator if it is a vector image. The problem is how to determine that.
Since it is before the file is opened, I need to reference the XMP or parse the file.
For the moment, I found that it can be determined to some extent by checking whether exif:PixelXDimension exists or not.
var pixelWidth = xmpMetaObj.getProperty(XMPConst.NS_EXIF, 'PixelXDimension').toString() ;
What are some of the more reliable methods? The file could have been saved using a non-Adobe app.
1 Correct answer
In the end, I decided to adopt exif:PixelXDimension. Thank you for your response.
Explore related tutorials & articles
Copy link to clipboard
Copied
Well, one problem is that most EPS files contain at least some pixel data, to serve as a proxy for the true vector data.
EPS was developed for the sake of letting early software like Aldus PageMaker quickly show a rough pixel-based depiction of the image on the screen (encapsulated as a separate part in the EPS file), while parsing the vector-based Adobe PostScript part directly to a printer, without actually interpreting it (that was/is handled by the official Adobe PostScript/PDF RIP in the printer). So PageMaker could handle PostScript imagery from drawing tools like Aldus FreeHand, without the costly and slow on-screen processing of the PostScript language.
That's how EPS begun.
But in the 80's and 90's, developers have created dozens of use-cases of an EPS for certain reasons. An EPS with a huge bit-image and a vector-based clipping masks, a lo-res EPS to connect 4 color-separated hi-res EPS files (DCS), an EPS containing one huge bitmap and some PostScript to define 2 or more color curves (e.g. Duotones), etcetera...
These have all been declared legacy (Photoshop files can hold such features natively now), but they're still around !
And in many other cases less proficient designers simply toss a bitmap image (like a logo or icon) in Adobe Illustrator, save it as an EPS or Illustrator file, hoping/thinking it becomes a vector image, and call it a day. Such an Illustrator file contains a tiny bit of PostScript (a vector rectangle, which holds a bunch of bitmap data). It probably also has been saved with "PDF complaince", meaning that it's actually wrapped as a PDF file, containing some extra AI resources (the PostScript and the bitmap), with an ".ai" extension slapped on it as the file name (so Illustrator will open it when double-clicking it...)
And to make it worse: especially in an AI file, there might rightfully be a creative mix of vectors and bitmap-based parts in it. And the same can be true for a PSD file.
So unless you're truly looking into the coded content of an AI, EPS, or PSD file, or simply look at it on-screen and zoom-in a lot, you never know what the file actually contains.
Copy link to clipboard
Copied
After hearing your explanation, I thought it was not necessary to make such a strict judgment.
As a premise, we can already determine if the file is an ai and if the eps was created in Illustrator, and it is accurate enough. These are treated as vectors even if they contain placed images in their contents.
The rest is to determine whether the eps is vector data created by an application other than Illustrator, or a raster image created by Photoshop or other applications. I am considering how to handle this edge case.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
File is prepared. All files are eps, although the file extension may change when downloading.
Copy link to clipboard
Copied
Which files are purely vector EPS and which are raster EPS?
Using ExifTool, I can find common entries in all 3 files, however, I'm not sure if any of them will be "bullet-proof" as metadata may be removed.
[PostScript] Creator : Adobe Illustrator(R) 29.2
[PostScript] Creator : Adobe Photoshop Version 26.1.0 20241113.r.121 158e617
[PostScript] Creator : Serif Affinity
[XMP-xmpMM] HistorySoftwareAgent : Adobe Illustrator 29.2 (Macintosh)
[XMP-xmpMM] HistorySoftwareAgent : Adobe Photoshop 26.1 (Macintosh), Adobe Photoshop 26.1 (Macintosh)
[XMP-xmpMM] HistorySoftwareAgent : Affinity Photo 2 2.5.7
To a lesser extent:
[PostScript] BoundingBox : 0 0 0 0 (Illustrator)
[PostScript] BoundingBox : 0 0 100 100 (Photoshop)
[PostScript] BoundingBox : 0 0 100 100 (Afinity)
So parsing the file as binary and then using a regex to find key entries would be my first suggestion.
P.S. I have attached text files of the ExifTool output. Attachments removed at request.
Copy link to clipboard
Copied
vector_illustrator.eps is vector, all others are raster.
If the program identifies by app name, such as Photoshop or Illustrator/Affinity Photo via Creator, History, etc., the program needs to have a table of which apps indicate which.
That is not practical, so for now the exif:PixelXDimension shown at the beginning is more promising. Nevertheless, thanks for the idea.
It would be appreciated if you could remove the Exiftool output as it contains my personal information. I have already downloaded it.
Copy link to clipboard
Copied
In the end, I decided to adopt exif:PixelXDimension. Thank you for your response.
Copy link to clipboard
Copied
You also need to remember that Photoshop files can also contain vector items, such as clipping paths and text, so EPS files saved from PS with such usually cannot be opened back into PS without having to re-rasterize everything, which is not what you probably want.
Pretty much all EPS files (EPSF) contains a Creator in the header of the file. That's really all you need to search for to determine where it came from:
Legacy files don't have XMP data as that's a more modern thing, so that can't be relied on. That being said, Illustrator .AI files, in addition to a CreatorTool item in XMP, will still have the EPSF Creator line in it.
Copy link to clipboard
Copied
It is not necessary to be that strict in judging.
The goal is to open the file in an app that is probably appropriate In this context. Once opened, the user will look at the result and decide if they like it or not.
In other words, the script will not malfunction if it makes the wrong decision, and the user will tolerate a Photoshop EPS containing vector data or an Illustrator EPS containing raster data.
It is just a matter of being helpful if it improves accuracy.

