Ruby Captcha Alternative 
June 18th, 2007
Having trouble with RMagic in Ruby on Rails? You can always do what I ended up doing today, and using the command line interface to ImageMagick instead of dealing with all the headaches I was having.
First, download ImageMagick. Compile it or get the binaries if on Win32.

Figure out your command line for convert to create an image, set the correct blurring and warbling filters. Eg:
Then, create a helper method to come up with a string and use system method to execute the command line and dump the file in the correct spot.
system(’convert -size 142×42 xc:white -font arial -pointsize 30 -tile pattern:checkerboard -annotate +10+30 ‘ + mystring + ‘ -blur 0×1 -wave 1×4 -draw “line ‘ + String((rand*142).round) + ‘,50 ‘ + String((rand*142).round) + ‘,0″ -draw “line ‘ + String((rand*142).round) + ‘,50 ‘ + String((rand*142).round) + ‘,0″ public/images/captcha/’ + filename + ‘.gif’)
resultstring = filename + “.gif”
|
Del.icio.us
This entry was posted on Monday, June 18th, 2007 at 7:59 pm and is filed under User Interface, web development, resources, rubyonrails. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
