I'm using Drupal 8. Is there a hook for generating image from image style or better one module?For example. I upload an image. When image is displayed for the first time, drupal generates image style. Can I hook to that event somehow, at best when uploading the image?
You don't need to write code to generate image styles in Drupal.
This functionality is provided by the Image module in Drupal core.
From the documentation:
To create or change image styles:
1. Choose Administration > Configuration > Media > Image styles.
2. Add or select a style to edit its settings.
3. When configuring styles you can add effects: crop, scale, resize, rotate, and desaturate (other contributed modules provide additional effects). For example, by combining effects as crop, scale, and desaturate, you can create square, grayscale thumbnails.
4. Save the settings.
To start using the defined styles they must be assigned to the display of a content type.
For each display (e.g. "default" or "teaser"), a different style can chosen.
To assign a style: