Exemplo n.º 1
0
 /**
  * Wil just return the resource as it is.
  *
  * {@inherit-doc}
  * @see GdWrapper\Action\MergeStrategy\Strategy::getMergeResource()
  */
 public function getMergeResource(Merge $action, Resource $src)
 {
     $mergeResource = $action->getMergeResource();
     $startPoint = $action->getStartPoint($src);
     $factory = $action->getResourceFactory($mergeResource->getWidth(), $mergeResource->getHeight());
     $cut = $factory->create();
     imagecopy($cut->getRaw(), $src->getRaw(), 0, 0, $startPoint->getX(), $startPoint->getY(), $cut->getWidth(), $cut->getHeight());
     imagealphablending($cut->getRaw(), true);
     imagecopy($cut->getRaw(), $mergeResource->getRaw(), 0, 0, 0, 0, $cut->getWidth(), $cut->getHeight());
     return $cut;
 }
Exemplo n.º 2
0
 /**
  * Wil just return the resource as it is.
  *
  * {@inherit-doc}
  * @see GdWrapper\Action\MergeStrategy.Strategy::getMergeResource()
  */
 public function getMergeResource(Merge $action, Resource $src)
 {
     return $action->getMergeResource();
 }
Exemplo n.º 3
0
use GdWrapper\Action\CropStrategy\FixedPoints as CropFixedPoints;
use GdWrapper\Action\CropStrategy\Proportional as CropProportional;
use GdWrapper\Action\CropStrategy\FixedDimensions as CropFixedDimensions;
use GdWrapper\Geometry\Point;
use GdWrapper\Geometry\Margin\Fixed as FixedMargin;
use GdWrapper\Geometry\Margin\Proportional as ProportionalMargin;
use GdWrapper\Geometry\Position\Aligned;
use GdWrapper\Geometry\Position\FixedPoint;
use GdWrapper\Geometry\Alignment\Start;
use GdWrapper\Geometry\Alignment\Center;
use GdWrapper\Geometry\Alignment\End;
header('content-type: image/png');
$iFactory = new ImageResourceFactory('test/assets/images/file1.jpg');
$src = $iFactory->create();
// PNG image with alpha transparency
$iFactory->setPathName('test/assets/images/file5.png');
$mergeRes = $iFactory->create();
$resize = new Resize(new ResizeKeepRatio(1800, 1000));
$resize->execute($src);
$crop = new Crop(new CropFixedDimensions(new Aligned(new Center()), 800, 500));
$crop->execute($src);
$merge = new Merge($mergeRes, new Aligned(new End(new FixedMargin(10))), 50, new SaveAlphaChannel());
$merge->setResourceFactoryClass('\\GdWrapper\\Resource\\TransparentResourceFactory');
$merge->execute($src);
$wFactory = new WriterFactory();
$writer = $wFactory->factory('png', $src->getRaw());
$writer->write(Writer::STDOUT);
// $resource = new EmptyResource(400, 300);
// $resourceFactory = new EmptyResourceFactory(400, 300);
// $writer = WriterFactory::factory('png', $resourceFactory->create());
// $writer->write(Writer::STDOUT);