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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
67bb4df2775f6a6b603347dce7119571?d=identicon&s=25 unknown (Guest)
on 2006-03-18 09:36
(Received via mailing list)
Dear Michael,

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

_http://www.imagemagick.org/script/identify.php_
(http://www.imagemagick.org/script/identify.php)  .

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_ (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,

Axel
This topic is locked and can not be replied to.