5

I have an encapsulated PostScript file which appears to only wrap an image file.

Is there a tool to extract the image data from it?

Nico Schlömer
  • 53,797
  • 27
  • 201
  • 249

2 Answers2

4

"convert" will use ghostscript to render the eps, and then continues with the rendered bitmap; this makes it difficult to get the original image back, in most cases you get a re-sampled image.

I understand that you want the image out in the original resolution. I haven't got a direct route for you. However, for getting images from pdf files, you can use pdfimages. Assuming you are running this on a Linux box (or with cygwin)

ps2pdf file.eps
pdfimages file.pdf basename

This gives you a basename.pnm or basename.ppm file. Use convert to get it to jpeg or png. If you had a lossy format (jpg) in the .eps, this would re-code the jpg, so some additional loss is unavoidable.

convert basename.pnm file.jpg

or

convert basename.ppm file.png

p.s. The file from the question is no longer available. However, this answer might still be of interest to others.

user3021380
  • 146
  • 3
0

ImageMagick can do that:

convert file.eps file.jpg

or you can do

convert file.eps file.png
convert file.eps file.tif

ImageMagick is available here.

example image

cr333
  • 1,555
  • 1
  • 15
  • 16
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
  • I would like to preserve the original data from the EPS file. How do I know the embedded file format? – Nico Schlömer Aug 06 '14 at 17:20
  • I do not understand :-) Which data do you mean? Surely you have the original image data in the EPS file already? – Mark Setchell Aug 06 '14 at 17:25
  • Indeed. It can be embedded as JPG, PNG, or a number of other formats. I would like to extract that exact data. With `convert`, I have to specify the output format unconditionally of how it is stored in the EPS. – Nico Schlömer Aug 06 '14 at 17:27
  • I still don't get it :-) If you subsequently need the data in a different format, just extract it to that format as I showed. If you want to look in the EPS file for some reason, you can use `strings file.eps | more` and you will see all the gory details. – Mark Setchell Aug 06 '14 at 17:35
  • 1
    I'm under the impression that EPS can encapsulate a number of different image files. I would like to extract whatever image file is stored in the EPS, without losing information. If a PNG is encapsulated and I `convert` into JPG, I lose information. I do not want that. – Nico Schlömer Aug 06 '14 at 17:43
  • My point is that you don't lose information because you stil have the EPS file and if you later wish to extract it a different way, you can. – Mark Setchell Aug 06 '14 at 18:07
  • This is not extraction, this is conversion. The size of the output file is very different -> this is not taking part of the original data. – Yaroslav Nikitenko Jul 06 '23 at 09:24