/** * @param \DarkLuk42\BoundingBox $bb the area to be cropped * * @return \DarkLuk42\Image the new cropped image */ public function crop(BoundingBox $bb) { $image = new self($bb->getWidth(), $bb->getHeight(), $this->getBackgroundColorObject()); $image->copyResampled($this, BoundingBox::createFromImage($image), $bb); return $image; }
public function scaleAs(BoundingBox $from, BoundingBox $to) { $this->scaleWidth($to->getWidth() / $from->getWidth()); $this->addLeft(($to->getLeft() - $from->getLeft()) / $to->getWidth() * $this->getWidth()); $this->scaleHeight($to->getHeight() / $from->getHeight()); $this->addTop(($to->getTop() - $from->getTop()) / $to->getHeight() * $this->getHeight()); }