/** * Creates crop point * * @param AbstractImage $abstractImage * @param int $width * @param int $height * * @return Point */ protected function createCropPoint(AbstractImage $abstractImage, $width, $height) { if (!is_numeric($width) || !is_numeric($height)) { throw new \LogicException('Provided values for width and height are not numeric!'); } $width = (int) $width; $height = (int) $height; $imageWidth = $abstractImage->getSize()->getWidth(); $imageHeight = $abstractImage->getSize()->getHeight(); if ($imageWidth < $width || $imageHeight < $height) { throw new ImageTooSmallException('Provided image is too small to be resize! Provide larger image.'); } $cropWidth = $imageWidth / 2 - $width / 2; $cropHeight = $imageHeight / 2 - $height / 2; $box = clone $this->box; $box->setWidth(round($cropWidth))->setHeight(round($cropHeight)); $this->point->setBox($box); return $this->point; }
/** * Test to string */ public function testToString() { $string = (string) $this->point->setBox($this->box); static::assertInternalType('string', $string); }