Forum: Ruby Re: validation of form whoch is a image

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
unknown (Guest)
on 2006-03-18 10:36
(Received via mailing list)
Dear Michael,

You can check the file properties a user submits using the free
software Imagemagick, which has a method 'identify' to it,

(  .

If it's a valid format, you get,e.g.,

identify rose.jpg
rose.jpg JPEG 640x480 DirectClass 87kb 0.050u  0:01

or else

identify my_ruby_script.rb  # (no image file)
 identify: No decode delegate for this image format  (my_ruby_script.rb)

and you can check on the responses whta to do next.

Imagemagick is a very powerful toolset for image treatment,
you can download it at the website above.
There are Ruby bindings available at

 _http://rmagick.rubyforge.org_ (  .

(I haven't checked whether 'identify' is among them, but if not,
you can still talk to Imagemagick as an external program, using
backticks or the system command or the open3 library.)

Please tell us about your luck in doing so ;-)

Best regards,

This topic is locked and can not be replied to.