/** * (non-PHPdoc) * @see Hbarcelos\GdWrapper\Action\Action::execute() */ public function execute(Resource $src) { $info = $this->mode->getCropInfo($src->getWidth(), $src->getHeight()); $factory = $this->getResourceFactory($info->getWidth(), $info->getHeight()); $dst = $factory->create(); imagecopyresampled($dst->getRaw(), $src->getRaw(), 0, 0, $info->getStartPoint()->getX(), $info->getStartPoint()->getY(), $dst->getWidth(), $dst->getHeight(), $dst->getWidth(), $dst->getHeight()); $src->setRaw($dst->getRaw()); }
/** * Resizes an image based on the mode passed in the constructor. * * {@inheritdoc} * * @see Hbarcelos\GdWrapper\Action\Action::execute() */ public function execute(Resource $src) { $dimensions = null; try { $dimensions = $this->mode->getNewDimensions($src->getWidth(), $src->getHeight()); } catch (\InvalidArgumentException $e) { throw new \UnexpectedValueException('The image seems to have no size at all.', $e->getCode(), $e); } $factory = $this->getResourceFactory($dimensions->getX(), $dimensions->getY()); $dst = $factory->create(); imagecopyresampled($dst->getRaw(), $src->getRaw(), 0, 0, 0, 0, $dst->getWidth(), $dst->getHeight(), $src->getWidth(), $src->getHeight()); $src->setRaw($dst->getRaw()); }