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());
 }
Ejemplo n.º 3
0
 /**
  * Shortcut for obtaining the start point of the position for the merged image.
  *
  * @param \GdWrapper\Action\MergeStrategy\Strategy $strategy The merge strategy.
  *
  * @return \GdWrapper\Geometry\Point The starting point of the position for the merged image.
  */
 public function getStartPoint(Resource $src)
 {
     return $this->position->getStartPoint(new Point($src->getWidth(), $src->getHeight()), new Point($this->mergeResource->getWidth(), $this->mergeResource->getHeight()));
 }