Page 1 of 1

eps to png barcode is blurry

Posted: 2013-04-25T11:19:15-07:00
by wfzimmerman
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.

Re: eps to png barcode is blurry

Posted: 2013-04-25T11:29:02-07:00
by fmw42
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?

Re: eps to png barcode is blurry

Posted: 2013-04-25T11:38:01-07:00
by wfzimmerman
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

Re: eps to png barcode is blurry

Posted: 2013-04-25T12:01:21-07:00
by fmw42
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%.

Re: eps to png barcode is blurry

Posted: 2013-04-27T09:03:05-07:00
by indiego
You can also try to add '+antialias' to your command line. Anti-aliasing pixels are not helpful when it comes to bar codes.

Re: eps to png barcode is blurry

Posted: 2013-04-27T10:09:16-07:00
by fmw42
I am not sure that anti-alias is used by anything but -draw?

Re: eps to png barcode is blurry

Posted: 2013-04-28T01:51:40-07:00
by indiego
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.