Apply Image styles for migrated images I've done a drupal migration from drupal 6 to drupal 8.
While all files are migrated well, image styles are not applying on migrated images.

Image styles are applied to the newly added images.

I think I should have force drupal to generate image styles for migrated images, but I don't know how.

any help one that is appreciated.

PS. I read some information about Flushing image styles in drupal 7 but I couldn't find a proper way to use it in drupal 8 as a custom module.
To solve the problem I used the code below to force Drupal to create the image styles for my nodes:

if ($entity-&gt;hasField('field_image') &amp;&amp; $entity-&gt;get('field_image')-&gt;getValue() != null) {
  $image = \Drupal::service('image.factory')-&gt;get($entity-&gt;get('field_image')-&gt;entity-&gt;getFileUri());
  if ($image-&gt;isValid()) {
    $styles = \Drupal::entityTypeManager()-&gt;getStorage('image_style')-&gt;loadMultiple();
    $image_uri = $entity-&gt;get('field_image')-&gt;entity-&gt;getFileUri();
    foreach ($styles as $style) {
      $destination = $style-&gt;buildUri($image_uri);
      $style-&gt;createDerivative($image_uri, $destination);
    }
  }
}


Here is the description, for each node ($entity variable) , first it checks if the node type has a field with machine name "field_image" and if this field has a value, then it checks if fileUri is a valid image, then if all conditions met, the code iterates on all image styles available and build that style for given image manually.

This code can be used as a cron job function, so on every cron job image styles of given nodes are created.