Has anyone implemented a captcha with ruby on rails and rmagick? I tried this example: http://wiki.rubyonrails.com/rails/pages/HowtoSecureFormsWithNoisyImages but I got an error: undefined method `size'' for #<NoisyImage:0x34d8070> Thank you -------------------------------------------------- Rodrigo Dominguez ? Iplan Networks ???????????????Datos Personales rdominguez@iplan.com.ar ??????rorra@rorra.com.ar www.iplan.com.ar ?????????????www.rorra.com.ar 5031-6303 ????????????????????15-5695-6027
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 Dominguez <rails@rorra.com.ar> wrote:> Has anyone implemented a captcha with ruby on rails and rmagick? > I tried this example: > http://wiki.rubyonrails.com/rails/pages/HowtoSecureFormsWithNoisyImages > but I got an error: > undefined method `size'' for #<NoisyImage:0x34d8070> > > Thank you > > > -------------------------------------------------- > > > Rodrigo Dominguez > > Iplan Networks Datos Personales > rdominguez@iplan.com.ar rorra@rorra.com.ar > www.iplan.com.ar www.rorra.com.ar > 5031-6303 15-5695-6027 > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Hi bakki I just copy and pastle your code and it''s working now, thank you, you did a great job, very easy to implement ;) ---------------------------- Rodrigo Dominguez ? Iplan Networks ??????????????? rdominguez@iplan.com.ar?????? www.iplan.com.ar??????????? 5031-6303 ???????????????????? Datos Personales rorra@rorra.com.ar www.rorra.com.ar 15-5695-6027 -----Mensaje original----- De: rails-bounces@lists.rubyonrails.org [mailto:rails-bounces@lists.rubyonrails.org] En nombre de Bakki Kudva Enviado el: Jueves, 09 de Marzo de 2006 06:25 p.m. Para: rails@lists.rubyonrails.org 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 Dominguez <rails@rorra.com.ar> wrote:> Has anyone implemented a captcha with ruby on rails and rmagick? > I tried this example: >http://wiki.rubyonrails.com/rails/pages/HowtoSecureFormsWithNoisyImages> but I got an error: > undefined method `size'' for #<NoisyImage:0x34d8070> > > Thank you > > > -------------------------------------------------- > > > Rodrigo Dominguez > > Iplan Networks Datos Personales > rdominguez@iplan.com.ar rorra@rorra.com.ar > www.iplan.com.ar www.rorra.com.ar > 5031-6303 15-5695-6027 > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails
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 Dominguez ? Iplan Networks ??????????????? rdominguez@iplan.com.ar?????? www.iplan.com.ar??????????? 5031-6303 ???????????????????? Datos Personales rorra@rorra.com.ar www.rorra.com.ar 15-5695-6027 -----Mensaje original----- De: rails-bounces@lists.rubyonrails.org [mailto:rails-bounces@lists.rubyonrails.org] En nombre de Bakki Kudva Enviado el: Jueves, 09 de Marzo de 2006 06:25 p.m. Para: rails@lists.rubyonrails.org 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 Dominguez <rails@rorra.com.ar> wrote:> Has anyone implemented a captcha with ruby on rails and rmagick? > I tried this example: >http://wiki.rubyonrails.com/rails/pages/HowtoSecureFormsWithNoisyImages> but I got an error: > undefined method `size'' for #<NoisyImage:0x34d8070> > > Thank you > > > -------------------------------------------------- > > > Rodrigo Dominguez > > Iplan Networks Datos Personales > rdominguez@iplan.com.ar rorra@rorra.com.ar > www.iplan.com.ar www.rorra.com.ar > 5031-6303 15-5695-6027 > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 3/9/06, Rodrigo Dominguez <rails@rorra.com.ar> wrote:> 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 >Here''s the problem. WHen you do ... image = NoisyImage.new(6) you are creating a NoisyImage object. The actual image binary is contained in the @code_image instance variable. If you see the code there are two accessor methods. First is :code (string) and the other :code_image (binary image data). So you will have to send it in your example as... send_data image.code_image, :type => ''image/jpeg'', :disposition => ''inline'' In my code I had done that earlier in the line... image = session[:noisy_image].code_image since I was saving the noisy_image object in the session. Hope that clarifies. bakki> the image is not displaying anymore, and I don''t know why... (actually, > that was the error that I was getting before) > > ---------------------------- > Rodrigo Dominguez > > Iplan Networks > rdominguez@iplan.com.ar > www.iplan.com.ar > 5031-6303 > > Datos Personales > rorra@rorra.com.ar > www.rorra.com.ar > 15-5695-6027 > > -----Mensaje original----- > De: rails-bounces@lists.rubyonrails.org > [mailto:rails-bounces@lists.rubyonrails.org] En nombre de Bakki Kudva > Enviado el: Jueves, 09 de Marzo de 2006 06:25 p.m. > Para: rails@lists.rubyonrails.org > 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 Dominguez <rails@rorra.com.ar> wrote: > > Has anyone implemented a captcha with ruby on rails and rmagick? > > I tried this example: > > > http://wiki.rubyonrails.com/rails/pages/HowtoSecureFormsWithNoisyImages > > but I got an error: > > undefined method `size'' for #<NoisyImage:0x34d8070> > > > > Thank you > > > > > > -------------------------------------------------- > > > > > > Rodrigo Dominguez > > > > Iplan Networks Datos Personales > > rdominguez@iplan.com.ar rorra@rorra.com.ar > > www.iplan.com.ar www.rorra.com.ar > > 5031-6303 15-5695-6027 > > > > > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
That was the error, thank you for your time ---------------------------- Rodrigo Dominguez ? Iplan Networks ??????????????? rdominguez@iplan.com.ar?????? www.iplan.com.ar??????????? 5031-6303 ???????????????????? Datos Personales rorra@rorra.com.ar www.rorra.com.ar 15-5695-6027 -----Mensaje original----- De: rails-bounces@lists.rubyonrails.org [mailto:rails-bounces@lists.rubyonrails.org] En nombre de Bakki Kudva Enviado el: Viernes, 10 de Marzo de 2006 12:44 a.m. Para: rails@lists.rubyonrails.org Asunto: Re: [Rails] rmagick and captcha On 3/9/06, Rodrigo Dominguez <rails@rorra.com.ar> wrote:> 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 >Here''s the problem. WHen you do ... image = NoisyImage.new(6) you are creating a NoisyImage object. The actual image binary is contained in the @code_image instance variable. If you see the code there are two accessor methods. First is :code (string) and the other :code_image (binary image data). So you will have to send it in your example as... send_data image.code_image, :type => ''image/jpeg'', :disposition => ''inline'' In my code I had done that earlier in the line... image = session[:noisy_image].code_image since I was saving the noisy_image object in the session. Hope that clarifies. bakki> the image is not displaying anymore, and I don''t know why...(actually,> that was the error that I was getting before) > > ---------------------------- > Rodrigo Dominguez > > Iplan Networks > rdominguez@iplan.com.ar > www.iplan.com.ar > 5031-6303 > > Datos Personales > rorra@rorra.com.ar > www.rorra.com.ar > 15-5695-6027 > > -----Mensaje original----- > De: rails-bounces@lists.rubyonrails.org > [mailto:rails-bounces@lists.rubyonrails.org] En nombre de Bakki Kudva > Enviado el: Jueves, 09 de Marzo de 2006 06:25 p.m. > Para: rails@lists.rubyonrails.org > 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 Dominguez <rails@rorra.com.ar> wrote: > > Has anyone implemented a captcha with ruby on rails and rmagick? > > I tried this example: > > >http://wiki.rubyonrails.com/rails/pages/HowtoSecureFormsWithNoisyImages> > but I got an error: > > undefined method `size'' for #<NoisyImage:0x34d8070> > > > > Thank you > > > > > > -------------------------------------------------- > > > > > > Rodrigo Dominguez > > > > Iplan Networks Datos Personales > > rdominguez@iplan.com.ar rorra@rorra.com.ar > > www.iplan.com.ar www.rorra.com.ar > > 5031-6303 15-5695-6027 > > > > > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails
You are welcome. Glad to help. -bakki On 3/10/06, Rodrigo Dominguez <rails@rorra.com.ar> wrote:> That was the error, thank you for your time > > ---------------------------- > Rodrigo Dominguez > > Iplan Networks > rdominguez@iplan.com.ar > www.iplan.com.ar > 5031-6303 > > Datos Personales > rorra@rorra.com.ar > www.rorra.com.ar > 15-5695-6027 > > -----Mensaje original----- > De: rails-bounces@lists.rubyonrails.org > [mailto:rails-bounces@lists.rubyonrails.org] En nombre de Bakki Kudva > Enviado el: Viernes, 10 de Marzo de 2006 12:44 a.m. > Para: rails@lists.rubyonrails.org > Asunto: Re: [Rails] rmagick and captcha > > On 3/9/06, Rodrigo Dominguez <rails@rorra.com.ar> wrote: > > 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 > > > > Here''s the problem. WHen you do ... > image = NoisyImage.new(6) > you are creating a NoisyImage object. The actual image binary is > contained in the @code_image instance variable. If you see the code > there are two accessor methods. First is :code (string) and the other > :code_image (binary image data). So you will have to send it in your > example as... > send_data image.code_image, :type => ''image/jpeg'', :disposition => > ''inline'' > > In my code I had done that earlier in the line... > image = session[:noisy_image].code_image > since I was saving the noisy_image object in the session. > > Hope that clarifies. > > bakki > > > the image is not displaying anymore, and I don''t know why... > (actually, > > that was the error that I was getting before) > > > > ---------------------------- > > Rodrigo Dominguez > > > > Iplan Networks > > rdominguez@iplan.com.ar > > www.iplan.com.ar > > 5031-6303 > > > > Datos Personales > > rorra@rorra.com.ar > > www.rorra.com.ar > > 15-5695-6027 > > > > -----Mensaje original----- > > De: rails-bounces@lists.rubyonrails.org > > [mailto:rails-bounces@lists.rubyonrails.org] En nombre de Bakki Kudva > > Enviado el: Jueves, 09 de Marzo de 2006 06:25 p.m. > > Para: rails@lists.rubyonrails.org > > 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 Dominguez <rails@rorra.com.ar> wrote: > > > Has anyone implemented a captcha with ruby on rails and rmagick? > > > I tried this example: > > > > > > http://wiki.rubyonrails.com/rails/pages/HowtoSecureFormsWithNoisyImages > > > but I got an error: > > > undefined method `size'' for #<NoisyImage:0x34d8070> > > > > > > Thank you > > > > > > > > > -------------------------------------------------- > > > > > > > > > Rodrigo Dominguez > > > > > > Iplan Networks Datos Personales > > > rdominguez@iplan.com.ar rorra@rorra.com.ar > > > www.iplan.com.ar www.rorra.com.ar > > > 5031-6303 15-5695-6027 > > > > > > > > > > > > > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >