How generate a barcode code128 via command line?

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
mbelgrano
Posts: 2
Joined: 2010-03-08T09:38:34-07:00
Authentication code: 8675308

How generate a barcode code128 via command line?

Post by mbelgrano »

Im using via command line follow
convert -font code-128 -pointsize 58 -fill black -size 400x100 xc:white -draw "text 20,80 'Ò,BÍ5VÓ'" barcmax.jpg
Print incorrect image of barcode
I am using Use code128 from http://sourceforge.net/projects/openbarcodes/

work right if print "Ò,BÍ5VÓ" via wordpad with "code 128" font selected
"Ò,BÍ5VÓ" is 12345 encoded

Thanks in advace
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: How generate a barcode code128 via command line?

Post by Bonzo »

Try this:

Code: Select all

convert -size 400x100 xc:white -font code128.ttf -pointsize 58 -fill black  -draw "text 20,80 'Ò,BÍ5VÓ'" barcmax.jpg
I have created the "canvas" first and put the correct filename of the barcode font.
carloskich
Posts: 2
Joined: 2018-01-23T08:47:03-07:00
Authentication code: 1152

Re: How generate a barcode code128 via command line?

Post by carloskich »

In code 128 there is the code '(apostrophe). I'm using the command:

convert -density 600 -size 2000x333 xc:white -font c:\windows\fonts\code128c.ttf -fill black -draw "text 20,333 'úC1,'D$dü!DYüHüNe;3UF'cjû' " C:\Carlos\dacte\test.jpg

The bar code is cutting because of the '

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

Re: How generate a barcode code128 via command line?

Post by fmw42 »

Have you tried using escaping the single quotes as \'.

This works fine for me on IM 6.9.9.23 Q16 Mac OSX

Code: Select all

convert -size 200x200 xc:white -fill black -font arial -pointsize 18 -draw "text 20,20 'abc\'def\'ghi'" tmp.png
carloskich
Posts: 2
Joined: 2018-01-23T08:47:03-07:00
Authentication code: 1152

Re: How generate a barcode code128 via command line?

Post by carloskich »

Thank you very much. Now it's 99%.

I still encounter problems running the command:

convert -density 600 -size 1500x333 xc:white -font c:\windows\fonts\code128c.ttf -fill black -draw "text 20,333 'úJ2!\'D$dü#&YüRü+7b-;"P/`û'" c:\carlos\test.jpg

When I run from the command line (DOS) it works perfectly.
But when I run with a BAT file, error occurs.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How generate a barcode code128 via command line?

Post by fmw42 »

Sorry I do not know Windows scripting. Try using Windows escapes ^' rather than \'
Post Reply