You can define custom image sizes for your site. Images are generated on upload or when regenerating thumbnails. Add to your functions.php file. For more on image optimization.
add_action( 'after_setup_theme', function() {
add_image_size( 'card-thumbnail', 400, 300, true );
add_image_size( 'hero-banner', 1920, 600, true );
} );Replace names and dimensions as needed. Use true for crop or false for scale.