Hello. I'm trying to build a php function that uploads an image to a server, creates a smaller copy of the image as a thumbnail, and saves both URLs into a database.

Thing I've done: I've got the code that uploads the image to the server working properly. I also sorted out how to save the URL into a database of the newly uploaded image.

Problem: -I can't figure out which code I need to duplicate the old image.
-I'm not sure how to resize the new image. I want it to be a minimum height and width of 100px, but I want it to scale properly instead of into a cube. (ie; if the image is longer than taller, the height would be 100px and the width would be more than 100px.)
-Also, when I save the thumb image to the server, would I be using similiar code I used to save the first image, or something else?