Skip to content

Instantly share code, notes, and snippets.

@artbikes
Created January 17, 2013 21:45
Show Gist options
  • Select an option

  • Save artbikes/4560081 to your computer and use it in GitHub Desktop.

Select an option

Save artbikes/4560081 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'RMagick'
captcha = "9277f49ecee"
#10.times { captcha << (rand(26)+65).chr }
canvas = Magick::Image.new(1280,800, Magick::HatchFill.new('#ffffff','#4169e1'))
text = Magick::Draw.new
text.annotate(canvas,0,0,0,0,captcha) {
self.fill = "#000000"
self.stroke = "transparent"
self.pointsize = 72
self.font_weight = Magick::BoldWeight
self.gravity = Magick::CenterGravity
}
canvas = canvas.swirl(30)
canvas = canvas.implode(-0.45)
data = canvas.to_blob { self.format = "jpg" }
puts data
@artbikes
Copy link
Copy Markdown
Author

ruby capt.rb > image.jpg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment