Preview:
#!/bin/bash
# create_barcode.sh
# sudo apt-get install barcode imagemagick

CODE=$1 #the code ... first parameter
FNAME=$2  #the filename .png .... second parameter (without file extension)

# let's create postscript:
barcode -E -b "$CODE" | convert -density 600 ps:- png:- > $FNAME

# use:
#   
#   bash create_barcode.sh 123456789 output.png  #it autodetect's the preferable encoding
#
#   this creates "output.png"
#
# Security Error:
#
# if you get security error: convert not authorized (ps/png) do this:
#
# edit /etc/ImageMagick-6/policy.xml
#
# disable this:

  <!--policy domain="coder" rights="none" pattern="PS" />-->

# and append this:

  <policy domain="coder" rights="read/write" pattern="PNG,PS" />
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter