Generating barcodes (as gif/jpg)

(Matt Pelletier) #1

Hello Rubyists,

I need to generate barcodes (in UPC and codabar symbologies) and would like to know if anyone has done this with Ruby. From what I can tell, it would be possible to use the gnu-barcode [1] or barcodewriter [2] to generate a PostScript, then through RMagick (via GhostScript) take the file and create a GIF/JPG.

These will really only be used for web display (to be printed and scanned elsewhere), so even though I'm referring to PS above it's not a necessary component. Any solution that takes a numeric code and generates a barcode as GIF/JPG is suitable.

I know there is a barcode gem (which uses RMagick directly) but it only works for the code-39 symbology. I'll be happy to add to it if it makes sense (and if the author is so inclined).

I have also seen various Perl/Python etc. tools out there. I can port it and gemmify if that's the best solution, but my hunch is PS -> RMagick -> GIF/JPG will be the most straightforward.

TIA,
Matt

[1] GNU-barcode (http://www.gnu.org/software/barcode/barcode.html)
[2] Barcode Writer (http://www.terryburton.co.uk/barcodewriter/)