/**
  * Compile the necessary data for the image crop effect.
  *
  * @param string $focal_point
  * @param int $image_width
  * @param int $image_height
  * @param int $crop_width
  * @param int $crop_height
  *
  * @return array|bool
  *   An array containing the following keys:
  *    - width
  *    - height
  *    - x
  *    - y
  */
 public static function calculateCropData($focal_point, $image_width, $image_height, $crop_width, $crop_height)
 {
     $crop_data = array();
     $parsed_focal_point = FocalPoint::parse($focal_point);
     // Get the pixel location of the focal point for the current image taking
     // the image boundaries into account.
     $crop_data['width'] = (int) $crop_width;
     $crop_data['height'] = (int) $crop_height;
     $crop_data['x'] = self::calculateAnchor($image_width, $crop_width, $parsed_focal_point['x-offset']);
     $crop_data['y'] = self::calculateAnchor($image_height, $crop_height, $parsed_focal_point['y-offset']);
     return $crop_data;
 }
 /**
  * Tests the parse() method.
  *
  * @dataProvider providerParseFocalPoint
  */
 public function testFocalPointParse($focal_point, $expected)
 {
     $this->assertSame($expected, FocalPoint::parse($focal_point));
 }