Forced image style generation

Last updated on 24/12/2016
// Load the file.
$file = file_load($fid);
 
// Related image style.
$image_style = 'my_image_style_name';
 
// New new image path.
$derivative_uri = image_style_path($style_name, $file->uri);
 
// Generate the image.
image_style_create_derivative(image_style_load($style_name), $file->uri, $derivative_uri);

To flush all the images of specific style:

image_style_flush('my_image_style_name');