It's probably not a good idea to create the scaled image at the same place like the original image. First, you are polluting the users albums and galleries that way, second we don't even know if we can write at that location, and third, it becomes hard to delete those temporary files.
That's why this temporary file should sit in a well defined directory under our control.