Personally, I'm not sure that's the best way to go about it.
I'd just use the rmagick interface.
With that you can get the width/height/type much easier. See these
(slightly verbose) examples.
In particular, you could use something like
img = Magick::Image.from_blob(file.read)
Then width & height are available in img.columns and img.rows