How to obtain the width an height of an image?

Hi friends i’ve problems to obtain the width and height of image, i want
to validate this, i follow the rmagick doc
(RMagick 1.15.0: Common Tasks) , but this only
work fine in shell, but in web the web server don’t respond (webrick or
mongrel), i’m using this code for validate and upload the image:

thanks to all!