I agree with Sinistral about the 'two different questions' issue. It seems from the language of the post that you may already know how to extract the image. I would also look at the Image::Magick module, as this not only has many features for modifying images, it can output in a multitude of formats as well