One way is to resize the image if the image size is different than what you expect. So you can check the size of the image that you read from file, and then apply resize that to your desired image size. However, depending on your application, it might be important to keep the aspect ratio. So, you can find proper ways.
Another way, is to use the transformations in torchvision.transforms. For example, if you apply torchvision.transforms.CenterCrop(size), then all your images will be cropped from the center of the image and having the same size.