# Validation of form whoch is a image

**URL:** <https://rubytalk.org/t/validation-of-form-whoch-is-a-image/25883>\
**Category:** ruby-talk\
**Created:** [18 March 2006 08:35 UTC](https://rubytalk.org/t/validation-of-form-whoch-is-a-image/25883 "2006-03-18T08:35:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nuralanur](https://avatars.discourse-cdn.com/v4/letter/n/90db22/32.png) [@Nuralanur](https://rubytalk.org/u/Nuralanur)\
**Post date:** [18 March 2006 08:35 UTC](https://rubytalk.org/t/validation-of-form-whoch-is-a-image/25883/1 "2006-03-18T08:35:42Z")

</div>

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](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](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
