Skip to content

Commit

Permalink
Merge remote-tracking branch 'matheusvilela/rmagick4jfix' into matheu…
Browse files Browse the repository at this point in the history
…svilela-pr-22

* matheusvilela/rmagick4jfix:
  Fix captcha generation using rmagick4j 0.3.8.

Ref: phatworx#22
  • Loading branch information
karlwilbur committed Aug 4, 2020
2 parents d3a0281 + 73a620d commit 7848248
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/easy_captcha/generator/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def generate(code)
end

# Render the text in the image
canvas.annotate(Magick::Draw.new, 0, 0, 0, 0, code) {
Magick::Draw.new.annotate(canvas, 0, 0, 0, 0, code) {
self.gravity = Magick::CenterGravity
self.font = config.font
self.font_weight = Magick::LighterWeight
Expand All @@ -88,7 +88,7 @@ def generate(code)
canvas = canvas.wave(rand(a.last - a.first) + a.first, rand(w.last - w.first) + w.first) if config.wave?

# Sketch
canvas = canvas.sketch(config.sketch_radius, config.sketch_sigma, rand(180)) if config.sketch?
canvas = canvas.sketch(config.sketch_radius, config.sketch_sigma, rand(180)) if config.sketch? && canvas.respond_to?('sketch')

# Implode
canvas = canvas.implode(config.implode.to_f) if config.implode.is_a? Float
Expand All @@ -110,7 +110,7 @@ def generate(code)
# ruby-1.9
image = image.force_encoding 'UTF-8' if image.respond_to? :force_encoding

canvas.destroy!
canvas.destroy! if canvas.respond_to?('destroy!')
image
end

Expand Down

0 comments on commit 7848248

Please sign in to comment.