Convert and resize .eps to .png

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
thatbradguy
Posts: 5
Joined: 2015-11-22T09:12:23-07:00
Authentication code: 1151

Convert and resize .eps to .png

Post by thatbradguy »

I'm using this command and getting very jagged results.

Code: Select all

mogrify -format png *.EPS -resize 2475x3525 -units PixelsPerInch -density 300
The eps is a vector file, so I would expect better results. Any help?

Input: https://dl.dropboxusercontent.com/u/9391254/AG1.EPS
Output: https://dl.dropboxusercontent.com/u/9391254/AG1.png
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert and resize .eps to .png

Post by snibgo »

I have no tools other than Ghostscript that can view the image. Do you have tools that suggest Ghostscript is wrong?

What makes you think the contents are vector? Looking at AG1.EPS with a text editor, it looks like a bitmap with no vector data. But I'm not an eps expert.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert and resize .eps to .png

Post by fmw42 »

Have you tried to use convert on one image rather than mogrify? In convert -density should come right before reading a vector file such as eps (if it is really vector data). I think your upload has changed your data. When I download your input, IM identify says it is PDF not EPS and it looks the same to me as your output result. Perhaps you should zip your input and upload that.
thatbradguy
Posts: 5
Joined: 2015-11-22T09:12:23-07:00
Authentication code: 1151

Re: Convert and resize .eps to .png

Post by thatbradguy »

First... thanks for the help.

Second... I can't even find the original source file so re-upload it so I've uploaded another from the same source and changed to using convert as suggested.

Code: Select all

convert -density 300 ES3pinstripes03bw.eps -units PixelsPerInch -resize 2475x3525 *.png
Input: https://dl.dropboxusercontent.com/u/939 ... es03bw.eps
Output: https://dl.dropboxusercontent.com/u/9391254/%2A.png

Now my output looks great as far as size and clarity. Two questions...

1. How can I get pngs with transparent backgrounds as output?
2. How can I run this command on all the files in a directory, or even better, recursively through subdirectories?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert and resize .eps to .png

Post by fmw42 »

I am not an expert on wild cards, but as far as I know, you cannot use *.png as an output name. You must specify a real name for the output file.

1) try

Code: Select all

convert -density 300 ES3pinstripes03bw.eps -units PixelsPerInch -resize 2475x3525 PNG32:ES3pinstripes03bw.png
2) you will have to write a script loop for whatever OS you are using to transverse the folder hierarchy and process each file as above.

Note that PNG does not allow PixelsPerInch, only PixelsPerCentimeter. But IM will convert it automatically.
thatbradguy
Posts: 5
Joined: 2015-11-22T09:12:23-07:00
Authentication code: 1151

Re: Convert and resize .eps to .png

Post by thatbradguy »

Your suggested code doesn't give me transparent background.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert and resize .eps to .png

Post by fmw42 »

Can you post the real input EPS? What I downloaded was just PDF from your link. It may be being converted from EPS to PDF when you upload to dropbox. Perhaps zip compress the EPS first and then upload it to dropbox. Is the EPS file actually transparent?

try

Code: Select all

convert -density 300 -background transparent ES3pinstripes03bw.eps -units PixelsPerInch -resize 2475x3525 PNG32:ES3pinstripes03bw.png
thatbradguy
Posts: 5
Joined: 2015-11-22T09:12:23-07:00
Authentication code: 1151

Re: Convert and resize .eps to .png

Post by thatbradguy »

Here is the input all zipped up. - https://dl.dropboxusercontent.com/u/939 ... bw.eps.zip

As to its transparency, when I open it in illustrator it shows up on a white background. When I open it in Photoshop it has a transparent background. So... I'm not sure.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert and resize .eps to .png

Post by fmw42 »

Your EPS file is in CMYK colorspace. You need to convert it to sRGB before processing it. This command works fine for me on IM 6.9.2.6 Q16 Mac OSX.

Code: Select all

convert -density 300 -colorspace sRGB -background transparent ES3pinstripes03bw.eps -units PixelsPerInch -resize 2475x3525 PNG32:ES3pinstripes03bw.png
thatbradguy
Posts: 5
Joined: 2015-11-22T09:12:23-07:00
Authentication code: 1151

Re: Convert and resize .eps to .png

Post by thatbradguy »

That worked! Thanks. Now to write a script to process through all of these files.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert and resize .eps to .png

Post by fmw42 »

try mogrify

Code: Select all

mogrify -format png -density 300 -colorspace sRGB -background transparent -units PixelsPerInch -resize 2475x3525 *.eps
It works for me.
Post Reply