/**
   * {@inheritdoc}
   */
  public function applyEffect(ImageInterface $image) {
    parent::applyEffect($image);

    // First, attempt to resize the image.
    $originalDimensions = $this->getOriginalImageSize();
    $resize_data = self::calculateResizeData($originalDimensions['width'], $originalDimensions['height'], $this->configuration['width'], $this->configuration['height']);
    if (!$image->resize($resize_data['width'], $resize_data['height'])) {
      $this->logger->error(
        'Focal point scale and crop failed while resizing using the %toolkit toolkit on %path (%mimetype, %dimensions)',
        [
          '%toolkit' => $image->getToolkitId(),
          '%path' => $image->getSource(),
          '%mimetype' => $image->getMimeType(),
          '%dimensions' => $image->getWidth() . 'x' . $image->getHeight(),
        ]
      );
      return FALSE;
    }

    // Next, attempt to crop the image.
    return $this->applyCrop($image);
  }
 /**
  * Test the resize calculation.
  *
  * @covers ::calculateResizeData
  *
  * @dataProvider calculateResizeDataProvider
  */
 public function testCalculateResizeData($image_width, $image_height, $crop_width, $crop_height, $expected) {
   $this->assertSame($expected, FocalPointEffectBase::calculateResizeData($image_width, $image_height, $crop_width, $crop_height));
 }
 /**
  * @dataProvider calculateAnchorProvider
  */
 public function testCalculateAnchor($image_size, $crop_size, $focal_point_offset, $expected)
 {
     $this->assertSame($expected, FocalPointEffectBase::calculateAnchor($image_size, $crop_size, $focal_point_offset));
 }
  /**
   * {@inheritdoc}
   *
   * @codeCoverageIgnore
   */
  public function applyEffect(ImageInterface $image) {
    parent::applyEffect($image);

    return $this->applyCrop($image);
  }