Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

remove the waste of time that is RMagick, so it can work successfully…

… with Heroku.
  • Loading branch information...
commit 9b922aa6ae0598df530c2a9cfc7fc3e637181b44 1 parent 19d937b
@perezd authored
Showing with 7 additions and 9 deletions.
  1. +2 −2 README.markdown
  2. +5 −7 lib/barcoder.rb
4 README.markdown
@@ -15,7 +15,7 @@ barcode_generator is an awesome plugin, however, it does not interact very well
#### Why didn't you just fork his plugin?
-Anuj appeared to not want to rely directly on the RMagick gem itself. Instead, he was calling imagemagick's configure command via Kernel#system. There is nothing wrong with this, but I did not want to add back this dependency if he didn't need/want it. Also, I substantially re-wrote how the plugin generates the barcode with gbarcode.
+I substantially re-wrote how the plugin displays barcodes, and I didn't want to have that break any pre-existing uses he was implementing it with.
#### Is your API compatible with barcode_generator?
@@ -50,7 +50,7 @@ in this case your view will look like:
First install these requirements:
1. gem for gbarcode
- 2. install native ImageMagick library (and RMagick)
+ 2. install native ImageMagick library (RMagick not necessary)
Next, install Barcoder:
12 lib/barcoder.rb
@@ -43,13 +43,11 @@ def to_barcode(str, options = {:encoding_format => DEFAULT_BARCODER_ENCODING })
# this is where the magic happens.
- stream = get_bytes_from_barcode(bc, print_options)
- data = Magick::Image::read_inline(Base64.encode64(stream))[0]
- data.format = output_format
+ data = `echo "#{get_bytes_from_barcode(bc, print_options)}" | convert eps: #{output_format}:`
# simple output strategy, define :output_type => :disk in the #to_barcode call if you want
# it to write out to the disk for you, otherwise it will be a data url stream.
- output_type == :disk ? barcode_to_disk(data, bc, output_format) : barcode_to_stream(data)
+ output_type == :disk ? barcode_to_disk(data, bc, output_format) : barcode_to_stream(data, output_format)
# support for the original barcode-generator plugin syntax.
@@ -65,7 +63,7 @@ def barcode_to_disk(data, barcode, output_format)
filename = "#{barcode.ascii.gsub(" ", "-")}.#{output_format}"
Dir.mkdir(BARCODE_STORAGE_PATH) unless"#{BARCODE_STORAGE_PATH}/#{filename}", 'w') do |f|
- f.write(data.to_blob)
+ f.write(data)
@@ -73,8 +71,8 @@ def barcode_to_disk(data, barcode, output_format)
# stream the barcode to the client as a data url. often times, the barcode
# filesize is so minute, that this is absolutely acceptable. NOTE: I intentionally
# draw my own img tag for this, image_tag doesn't really like this.
- def barcode_to_stream(data)
- src = "data:image/#{data.format};base64,#{Base64.encode64(data.to_blob)}"
+ def barcode_to_stream(data, format)
+ src = "data:image/#{format};base64,#{Base64.encode64(data)}"
%Q{<img src="#{src}" />}
Please sign in to comment.
Something went wrong with that request. Please try again.