Resize image before load

Hello everybody.
I need to resize an image with predefined formats before the user loads it and in the same way have it downloaded in different formats by a second user.
It’s not necessary to compress the file, just reduce the size
I have tried various systems, but I can only check the size and give an error message, never reduce it.
Do you kindly know how to help me?
I am stuck unable to finish the job.

Thank you so much