Exemplo n.º 1
0
 /**
  * (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());
 }
Exemplo n.º 2
0
 /**
  * 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());
 }
Exemplo n.º 3
0
 /**
  * Shortcut for obtaining the start point of the position for the merged image.
  *
  * @param Hbarcelos\GdWrapper\Action\MergeMode\Mode $mode The merge mode.
  *
  * @return Hbarcelos\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()));
 }