I don't think these last four lines make sense.  Given the way you've defined thumbnailHeight, scalex and scaley are going to be identical.

If thumbnailWidth is the width of the available area for displaying the preview image, then I think you also have to pass in the corresponding height, so that you can properly letterbox the preview to the space available. As this code stands, if the photo and the screen space don't have the same aspect ratio, and the image is taller than it is high, I think you'll get a preview image that is bigger than the space you have to display it in.