Use the same image 2 times in image styles A tricky question regarding image styles.

I need to do a thumbnail with 2 layers:


background: a cropped picture with a blur effect.
foreground: overlay with the same picture and scale effect.


If you have some hints, or you know how to do it programmatically in a custom ImageEffect plugin I would appreciate any help.

This is an example how the image should look like:
I have solved the task currently without a custom image style. Only custom code:

/**
   * Applies an image effects blur, scale and crop.
   *
   * The result is am image with 2 layers:
   *   - background: a cropped picture with a blur effect.
   *   - foreground: overlay with the same image and scale effect.
   *
   * @param int $width
   *   Result image width.
   * @param int $height
   *   Result image height.
   * @param int $radius
   *   Result image blur radius.
   */
  public function blurScaleAndCrop($width, $height, $radius) {
    $image = $this-&gt;getImageFactory()-&gt;get($this-&gt;path);
    if (!$image-&gt;isValid()) {
      throw new \InvalidArgumentException("Image {$this-&gt;path} is not valid");
    }

    // Create the background image.
    $image-&gt;scaleAndCrop($width, $height);
    /** @var \Drupal\system\Plugin\ImageToolkit\GDToolkit $toolkit */
    $toolkit = $image-&gt;getToolkit();
    $resource = $toolkit-&gt;getResource();
    // Apply blur.
    if ($radius) {
      for ($i = 0; $i &lt; $radius; $i++) {
        imagefilter($resource, IMG_FILTER_GAUSSIAN_BLUR);
      }
    }
    $image-&gt;apply('gaussian-blur', ['radius' =&gt; $radius]);

    // Create the foreground image.
    $foreground = $this-&gt;getImageFactory()-&gt;get($this-&gt;path);
    if (!$foreground-&gt;isValid()) {
      throw new \InvalidArgumentException("Image {$this-&gt;path} is not valid");
    }
    $foreground-&gt;scale($width, $height);

    // Merge the 2 image layers.
    $dst_im = $image-&gt;getToolkit()-&gt;getResource();
    $src_im = $foreground-&gt;getToolkit()-&gt;getResource();
    $f_width = $foreground-&gt;getWidth();
    $f_height = $foreground-&gt;getHeight();
    $x = ($width - $f_width) / 2;
    $y = ($height - $f_height) / 2;
    imagecopy($dst_im, $src_im, $x, $y, 0, 0, $f_width, $f_height);
    $image-&gt;save();
  }