Hello,
First time posting on the ImageMagick forum.
Here is the scenario:
Most documents in our office have a barcode on them.
We have software that can read barcodes in tiff images.
We want to scan the documents into our server as pdf files and use convert to generate a tiff copy for the barcode software to read.
Once the barcode is decoded, a program can use the information in the barcode to organize the pdf files.
Have been trying different convert option to get a clean tiff image from the scanned pdf files. The cleaner (more defined) the barcode images are, the fewer documents get kicked out that have to be manually organized.
Have tried various convert options (mainly combinations including -threshold and -adaptive-sharpen) with marginal success.
Was wondering if anyone has tackled a similar issue, that might be able to provide some advice.
I included a link to a test barcode image:
http://imgur.com/3FqY62Y
So basically, need to convert a pdf file to a tiff file while retaining as much detail in the image as possible. Ideally the resulting tiff file would be similar in size to the original pdf. (Not a big deal if the tiff file is a little bigger, but sometimes in my testing the file size of the tiff file would be over 10x the file size of the original pdf.)
Also, if other convert options can help make the barcodes cleaner (darker, with more well-defined edges) that would be super.
Appreciate any help or guidance provided.
Thank you.
Respectfully,
Brad
convert - pdf to tiff for reading barcodes
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: convert - pdf to tiff for reading barcodes
The bar code elements are approx one pixel wide. Results are bound to be dreadful.
And you have already converted pdf to png. Why and how? Did that software rasterize a vector image, or resample a raster image?
And you have already converted pdf to png. Why and how? Did that software rasterize a vector image, or resample a raster image?
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: convert - pdf to tiff for reading barcodes
I think you need to read in your PDF images at a higher density before converting to TIFF, so that bar codes are more readable.
convert -density 300 image.pdf image.tif
for example. Use whatever density works for your OCR device.
convert -density 300 image.pdf image.tif
for example. Use whatever density works for your OCR device.
Re: convert - pdf to tiff for reading barcodes
snibgo, looks like imgur.com comverted my original pdf file to a png and compressed the image quite a bit.
The original pdf is scanned in at 200 dpi.
Let's try this again...
http://www.mediafire.com/view/2p6im53sg ... rcodes.pdf
I checked the file after it had been uploaded this time...it appears to be unaltered.
The original pdf is scanned in at 200 dpi.
Let's try this again...
http://www.mediafire.com/view/2p6im53sg ... rcodes.pdf
I checked the file after it had been uploaded this time...it appears to be unaltered.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: convert - pdf to tiff for reading barcodes
Yes, much better.
Can your code reader read these? They could be de-skewed and made slightly darker.
Code: Select all
convert -density 200 barcodes.pdf b.png
snibgo's IM pages: im.snibgo.com
Re: convert - pdf to tiff for reading barcodes
After some trial and error, here is the list of options that produced the best results for me (in case someone else ever has a similar request):
convert -density 200x200 -contrast -adaptive-sharpen 0x.6 -colorspace gray -colors 2 +dither -type bilevel file.pdf file.tiff
This combination seemed to remove any gray areas between adjacent barcode lines and produced a high contrast image for the barcode reader software to try to decode.
If someone knows ways I should further tweak this...by changing the order of options, or remove redundant or needless options; please let me know.
I also found a posting which stated the proper convert syntax has the input file at the beginning, then the options, and finally the output file at the end of the convert command.
I tried this and it did not seem to work.
Is there some order-of-operations for convert options?
Thanks,
B
convert -density 200x200 -contrast -adaptive-sharpen 0x.6 -colorspace gray -colors 2 +dither -type bilevel file.pdf file.tiff
This combination seemed to remove any gray areas between adjacent barcode lines and produced a high contrast image for the barcode reader software to try to decode.
If someone knows ways I should further tweak this...by changing the order of options, or remove redundant or needless options; please let me know.
I also found a posting which stated the proper convert syntax has the input file at the beginning, then the options, and finally the output file at the end of the convert command.
I tried this and it did not seem to work.
Is there some order-of-operations for convert options?
Thanks,
B
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: convert - pdf to tiff for reading barcodes
That order is generally for raster input images. For vector formats, you need to put -density and/or -colorspace before reading the input and then put the image processing commands after the reading the input, though it likely won't matter if it is before.I also found a posting which stated the proper convert syntax has the input file at the beginning, then the options, and finally the output file at the end of the convert command.
I tried this and it did not seem to work.
Is there some order-of-operations for convert options?
I would write it as follows to be safe
Code: Select all
convert -density 200x200 file.pdf -contrast -adaptive-sharpen 0x.6 -colorspace gray +dither -colors 2 -type bilevel file.tiff