Ejemplo n.º 1
0
 /**
  * (non-PHPdoc)
  * @see GdWrapper\Action\Action::execute()
  */
 public function execute(Resource $src)
 {
     $info = $this->strategy->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());
 }
Ejemplo n.º 2
0
 /**
  * Resizes an image based on the strategy passed in the constructor.
  *
  * {@inheritdoc}
  *
  * @see GdWrapper\Action\Action::execute()
  */
 public function execute(Resource $src)
 {
     $dimensions = null;
     try {
         $dimensions = $this->strategy->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());
 }