Created
March 16, 2010 08:33
-
-
Save helmerj/333765 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -rupN barcode-generator.orig//lib/barcode_generator.rb barcode-generator/lib/barcode_generator.rb | |
--- barcode-generator.orig//lib/barcode_generator.rb 2010-03-16 08:35:52.000000000 +0100 | |
+++ barcode-generator/lib/barcode_generator.rb 2010-03-16 08:39:19.249560958 +0100 | |
@@ -17,7 +17,7 @@ module ActionView | |
include ImageMagickWrapper | |
- VALID_BARCODE_OPTIONS = [:encoding_format, :output_format, :width, :height, :scaling_factor, :xoff, :yoff, :margin ] | |
+ VALID_BARCODE_OPTIONS = [:encoding_format, :output_format, :width, :height, :scaling_factor, :xoff, :yoff, :margin, :resolution , :antialias ] | |
def barcode(id, options = {:encoding_format => DEFAULT_ENCODING }) | |
@@ -51,7 +51,7 @@ module ActionView | |
File.open(eps,'wb') do |eps_img| | |
Gbarcode.barcode_print(bc, eps_img, print_options) | |
eps_img.close | |
- convert_to_png(eps, out) | |
+ convert_to_png(eps, out, options[:resolution], options[:antialias]) | |
end | |
#delete the eps image, no need to accummulate cruft | |
diff -rupN barcode-generator.orig//lib/imagemagick_wrapper.rb barcode-generator/lib/imagemagick_wrapper.rb | |
--- barcode-generator.orig//lib/imagemagick_wrapper.rb 2010-03-16 08:35:52.000000000 +0100 | |
+++ barcode-generator/lib/imagemagick_wrapper.rb 2010-03-16 08:53:03.856561007 +0100 | |
@@ -1,8 +1,15 @@ | |
module ImageMagickWrapper | |
# call imagemagick library on commandline thus bypassing RMagick | |
# memory leak hasseles :) | |
- def convert_to_png(src, out) | |
+ def convert_to_png(src, out, resolution, antialias) | |
#more options : convert +antialias -density 150 eps png | |
- system("convert #{src} #{out}") | |
+ options = [] | |
+ if resolution.present? | |
+ options << "-density #{resolution}" | |
+ elsif antialias == 1 | |
+ options << "+antialias" | |
+ end | |
+ | |
+ system("convert #{options.collect.join(' ')} #{src} #{out}") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment