Best command to convert 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
fablau
Posts: 7
Joined: 2012-01-23T17:53:40-07:00
Authentication code: 8675308

Best command to convert EPS to PNG?

Post by fablau »

Hello here,
I am trying to convert an EPS image to a PNG image with either convert, mogrify or any other command you may suggest. My problem is that I need to convert sheet music (so, no color needed), the image must be NOT aliased, at 224.993 dpi and size 1863x2636 and the size must be reasonable small.

To give you an example, here is a sample source file I use:

https://www.dropbox.com/s/2o4nzf6o2kb1x ... e.eps?dl=1

And here is the image I have converted manually with Photoshop (just imported without the Anti-aliased option checked, width of 1859, height of 2631 and resolution of 224.993 dpi, and a very small file:

https://www.dropbox.com/s/h1pou6eb3yw11 ... n.png?dl=1

I'd like to accomplish the same kind of destination file from the same source by using either convert, mogrify or whatever else you can suggest.

Thanks in advance to everybody!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Best command to convert EPS to PNG?

Post by fmw42 »

Your image is CMYK black on transparency. So you need to convert to sRGB. So try this

Code: Select all

convert -colorspace sRGB -density 300 SinglePageSource.eps -background white -flatten -resize 1863x2636 -units pixelsperinch -density 224.993 SinglePageSource_im.png
or you may get higher quality, but slower processing if you do

Code: Select all

convert -colorspace sRGB -density 600 SinglePageSource.eps -background white -flatten -resize 1863x2636 -units pixelsperinch -density 224.993 SinglePageSource_im2.png
fablau
Posts: 7
Joined: 2012-01-23T17:53:40-07:00
Authentication code: 8675308

Re: Best command to convert EPS to PNG?

Post by fablau »

Thank you for your suggestion, I get pretty good quality but nothing compared to what I can accomplish with Photoshop (see my sample png file above). How do you think I could achieve that kind of quality at such small file size? (just 57KB!)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Best command to convert EPS to PNG?

Post by fmw42 »

My second result is better quality than your PS result. You can see that in my result the bars connecting notes are perfectly horizontal. In your PS result, some of the bars are stair-stepped. ImageMagick is using Ghostscript to read your EPS file. My GS version is 9.21. Perhaps you need to upgrade. The file size of your PS is smaller. To achieve a smaller result, you will need to take my result and use a PNG compression tool, such as listed at http://www.imagemagick.org/Usage/formats/#png_non-im. PNGCRUSH OR OPTIPNG, for example.
fablau
Posts: 7
Joined: 2012-01-23T17:53:40-07:00
Authentication code: 8675308

Re: Best command to convert EPS to PNG?

Post by fablau »

You are right about the fact some note beamings are stair-stepped, but if you look at the staff lines they are much finer in the PS version, and all exactly 1 px high. In your version are all 3 pixels high and their are not all the same (grey colors differ from each other). Is there any way to accomplish that with Imagemagick?

Thank you again very much!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Best command to convert EPS to PNG?

Post by fmw42 »

Look at the text on the left side of sheet. You will see that your PS results are aliased badly, whereas the ImageMagick result has smooth antialiased text.

Imagemagick used Ghostscript to read your image. That is where the results are achieved. GS must process it differently from PS. You can try using Ghostscript directly, but I do not know of any controls to set the note line width. The thicker lines is probably due the better antialiasing in the ImageMagick result.

You could use -morphology to thin the lines, but then it might do more damage than good.

You will have to decide on the pros and cons of both method.
fablau
Posts: 7
Joined: 2012-01-23T17:53:40-07:00
Authentication code: 8675308

Re: Best command to convert EPS to PNG?

Post by fablau »

Thank you for your reply and help, I'll see what to do then.

Appreciated!
Post Reply