Change record status: 
Project: 
Introduced in branch: 
8.0.x
Description: 

Method ImageStyle::transformDimensions() passes the original image file uri (that itself received from e.g. the 'image_style' or 'responsive_image' themes) to the effects. The effects can use this information to access metadata (e.g. manual crop information, image EXIF data) to help determine the dimensions of the image derivative after the effect has been actually applied to the image.

Example:

Before:

Dimensions are set in configuration.

class MyImageEffect extends ConfigurableImageEffectBase {
  ...

  /**
   * {@inheritdoc}
   */
  public function transformDimensions(array &$dimensions) {
    // The new image will have the exact dimensions defined for the effect.
    $dimensions['width'] = $this->configuration['width'];
    $dimensions['height'] = $this->configuration['height'];

  ...

  }

}

After:

Dimensions depend on the image file extension:

class MyImageEffect extends ConfigurableImageEffectBase {
  ...

  /**
   * {@inheritdoc}
   */
  public function transformDimensions(array &$dimensions, $uri) {
    $extension = pathinfo($uri, PATHINFO_EXTENSION);
    switch (strtolower($extension)) {
      case 'png':
        $dimensions['width'] = $dimensions['height'] = 100;
        break;

      default:
        $dimensions['width'] = $dimensions['height'] = 20;
        break;

    }
  ...

  }

}

Impacts: 
Module developers