There is something that I just can’t understand…
In the article, you wrote this:
def protect
unless session[:noisy_image]
session[:noisy_image] = NoisyImage.new(6)
session[:code] = session[:noisy_image].code
end
end
def code_image
image = session[:noisy_image].code_image
send_data image, :type => ‘image/jpeg’, :disposition => ‘inline’
end
but if I write
def code_image
image = NoisyImage.new(6)
send_data image, :type => ‘image/jpeg’, :disposition => ‘inline’
end
the image is not displaying anymore, and I don’t know why… (actually,
that was the error that I was getting before)
Rodrigo D.
Iplan Networks
[email protected]
www.iplan.com.ar
5031-6303
Datos Personales
[email protected]
www.rorra.com.ar
15-5695-6027
-----Mensaje original-----
De: [email protected]
[mailto:[email protected]] En nombre de Bakki K.
Enviado el: Jueves, 09 de Marzo de 2006 06:25 p.m.
Para: [email protected]
Asunto: Re: [Rails] rmagick and captcha
Hi Rodrigo,
I am the author of the article in your msg.
I am not sure how you are getting that error. The NoisyImage class has
no other methods defined other than the initialize code. Which gets
called when you do session[:noisy_image] = NoisyImage.new(6).
The image size is hard coded in the NoisyImage class and you can
change it to whatever size you want on this line, in the NoisyImage
class…
canvas.new_image(32*len, 50, Magick::TextureFill.new(granite))
If you’d like you can create some vars named height and width and use
them instead.
width = 32 (or whatever - this is a per character width which gets
multiplied by the length of the code string, which you can also change
in you call to NoisyImage.new(length) I have it hard coded at six
chars.
height = 50
canvas.new_image(width*len, height, Magick::TextureFill.new(granite))
Hope it solves your problem.
bakki
On 3/9/06, Rodrigo D. [email protected] wrote:
Has anyone implemented a captcha with ruby on rails and rmagick?
I tried this example:
http://wiki.rubyonrails.com/rails/pages/HowtoSecureFormsWithNoisyImages
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails