eps to png barcode is blurry

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
wfzimmerman
Posts: 8
Joined: 2013-04-17T11:31:14-07:00
Authentication code: 6789

eps to png barcode is blurry

Post by wfzimmerman » 2013-04-25T11:19:15-07:00

Hi

Must be doing something simple wrong...

I am using Judah Milgram's bookland program to create an EPS bar code to lay on a book cover.

http://www.tux.org/~milgram/bookland/

I want to convert the resulting ISBN.eps file to a PNG. The barcode object on the book cover is supposed to be 1.75 x 0.98 " on a 300 dpi page and very crisp. Unfortunately, the PNG keeps coming out way too blurry.

I am doing

convert -density 300 -units pixelsperinch barcode.eps barcode.png

I have tried upping the density and I have tried using -resize 126x71. Even at very high densities it is still blurry and at 126x71 it becomes tiny.

User avatar
fmw42
Posts: 25399
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: eps to png barcode is blurry

Post by fmw42 » 2013-04-25T11:29:02-07:00

PNG does not support dpi, only dots per centimeter. So Imagemagick is (supposed to) convert your 300 dpi to the equivalent dpc automatically. Check the verbose information on the png and see what is shows for resolution and units. It should be 300x2.54=762 dpc

identify -verbose yourimage

What version of IM are your using and on what platform? Perhaps you have an old version that has a bug?

wfzimmerman
Posts: 8
Joined: 2013-04-17T11:31:14-07:00
Authentication code: 6789

Re: eps to png barcode is blurry

Post by wfzimmerman » 2013-04-25T11:38:01-07:00

That's odd.

1) the EPS that bookland generates is 72 x 72.

2) the result of

convert -units "PixelsPerInch" -density 300 -colorspace CMYK images/$uuid/print/$userprovidedprintISBN.eps -density 300 images/$uuid/print/$userprovidedprintISBN.png

is an image that is

Geometry: 671x396+0+0
Resolution: 118.11x118.11

ImageMagick 6.7.7-10 2012-08-17 Q on Ubuntu 12.10

User avatar
fmw42
Posts: 25399
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: eps to png barcode is blurry

Post by fmw42 » 2013-04-25T12:01:21-07:00

wfzimmerman wrote:That's odd.

1) the EPS that bookland generates is 72 x 72.

2) the result of

convert -units "PixelsPerInch" -density 300 -colorspace CMYK images/$uuid/print/$userprovidedprintISBN.eps -density 300 images/$uuid/print/$userprovidedprintISBN.png

is an image that is

Geometry: 671x396+0+0
Resolution: 118.11x118.11

ImageMagick 6.7.7-10 2012-08-17 Q on Ubuntu 12.10

EPS files do not really have any density, but you can consider them nominally as 72 dpi.

My mistake, the conversion from dpi to dpc is properly dpi/2.54, so 300/2.54=118 dpc (since a cm is smaller than an inch by a factor of 2.54, there will be fewer dots in a cm at the same resolution compared to an inch worth of dots)

What units does the verbose information show for your resulting image?

For higher quality, try increasing the density before reading the eps. Use a value larger than 300, say 600 or 1200.

You can also try resizing before converting to png by adding -resize. If you use -density 600 (that is twice what you have), then -resize 50%. If you use -density 1200 (that is 4x what you have at 300), then -resize 25%.

indiego
Posts: 75
Joined: 2010-10-16T06:35:10-07:00
Authentication code: 8675308

Re: eps to png barcode is blurry

Post by indiego » 2013-04-27T09:03:05-07:00

You can also try to add '+antialias' to your command line. Anti-aliasing pixels are not helpful when it comes to bar codes.

User avatar
fmw42
Posts: 25399
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: eps to png barcode is blurry

Post by fmw42 » 2013-04-27T10:09:16-07:00

I am not sure that anti-alias is used by anything but -draw?

indiego
Posts: 75
Joined: 2010-10-16T06:35:10-07:00
Authentication code: 8675308

Re: eps to png barcode is blurry

Post by indiego » 2013-04-28T01:51:40-07:00

fmw42 wrote:I am not sure that anti-alias is used by anything but -draw?
I guess you are right. But at some point of the conversion from postscript you have to 'draw' the barcode lines.

Post Reply