Nothing is ever impossible I'm afraid, but this one would be very hard to pull off.
To have a virus in the resized image, the attacker would have to make its virus in a way that is:
- Innofensive gibberish when uploaded, but
- Materialized as the actual virus by the resizing algorithm.
So given the attacker has the choice of resizing algorithm and the final dimensions of the image, he would need to:
- Create a virus or attack vector that targets a vulnerability in an unsuspecting client (like a buffer overflow in a popular web browser)
- Run the virus in some "reverse resizing algorithm" and embeed the results in a way that will trigger the vulnerability after the image resize (step 4 below)
- Upload the rigged, but still innofensive image
- Let the server resize the image to make the virus designed at step 1 "appear" in the image
- Wait for an unsuspecting user to download the resized image, triggering the attack (exploit the buffer overflow, in this example)
If the attacker can't pick the algorithm or size, he can certainly run some tests and find out the runtime characteristics of the server, but it will make writing the "reverse resizing algorihtm" of step 2 harder and custom, increasing the (already high) cost of this attack.
Top of my head, adding a random steganographic marker to either (or both) images would send the cost and complexity of this attack out of the ball park.