When does WP resize an image file

WordPress resizes the image when you upload it. By default it provides 4 sizes of your image (providing your image is bigger than the ‘large’ size).

the_post_thumbnail(‘thumbnail’); // Thumbnail (default 150px x
150px max) the_post_thumbnail(‘medium’); // Medium resolution
(default 300px x 300px max) the_post_thumbnail(‘large’); //
Large resolution (default 640px x 640px max)
the_post_thumbnail(‘full’); // Original image resolution
(unmodified)

Source: https://codex.wordpress.org/Post_Thumbnails

You can use the add_image_size() function to specify your own sized images like this:

add_image_size( 'wpse-custom-size', 320, 340);

If there’s a chance you might be receiving images of all different sizes and proportions then you may want to crop the image when it’s resized. You can do this by providing true as the last argument.

add_image_size( 'wpse-custom-size', 320, 340, true);

Once you have done that, all images that you upload (it won’t change the ones that have already been uploaded) will now be available at that size using:

the_post_thumbnail('wpse-custom-size');

Hope that helps.