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.,
rose.jpg JPEG 640x480 DirectClass 87kb 0.050u 0:01
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
(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