From 7b4946ba1407bb94b020a28c5cb74e9cf11de475 Mon Sep 17 00:00:00 2001 From: Guillaume DOTT Date: Fri, 11 Jan 2013 14:58:37 +0100 Subject: [PATCH] Add width and height config for PlainCaptcha --- README.md | 2 ++ lib/really_simple_captcha/captcha/plain_captcha.rb | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 418b628..6b24dc3 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,8 @@ ReallySimpleCaptcha::Captcha::PlainCaptcha.configure do |config| # font size config.pointsize = 22 # image modification options + config.width = 120 + config.height = 40 config.implode_amount = 0.2 config.wave_amplitude = 4.0 config.wave_length = 60.0 diff --git a/lib/really_simple_captcha/captcha/plain_captcha.rb b/lib/really_simple_captcha/captcha/plain_captcha.rb index 4dcae78..1bb6ebf 100644 --- a/lib/really_simple_captcha/captcha/plain_captcha.rb +++ b/lib/really_simple_captcha/captcha/plain_captcha.rb @@ -6,6 +6,9 @@ module ReallySimpleCaptcha::Captcha include ActiveSupport::Configurable config_accessor :field_name + config_accessor :width + config_accessor :height + config_accessor :implode_amount config_accessor :wave_amplitude config_accessor :wave_length @@ -53,6 +56,9 @@ module ReallySimpleCaptcha::Captcha end def self.generate_image(captcha_text, args={}) + width = args[:width] || 120 + height = args[:height] || 40 + wave_amplitude = args[:wave_amplitude] || 4.0 wave_length = args[:wave_length] || 60.0 implode_amount = args[:implode_amount] || 0.2 @@ -62,7 +68,7 @@ module ReallySimpleCaptcha::Captcha background_color = args[:background_color] || 'white' - image = ::Magick::Image.new(120, 40) do + image = ::Magick::Image.new(width, height) do self.background_color = background_color end