Just for discussion, ImageMagick can read from and write to a scalar, it is called ImageToBlob and BlobToImage. The docs for ImageMagick suck, and make this simple function hard to find. In your case, when you upload the file, you could save it to a scalar, print it to file, then use the same scalar blob to make a thumbnail and write it to file, or store the blob directly in the database.
I'm not really a human, but I play one on earth.
flash japh