WIP for copyright.

This commit is contained in:
Malte Hübner 2018-02-17 01:47:31 +01:00
parent a549247a11
commit 6008660afc

View File

@ -2,12 +2,14 @@
namespace StaticMapLite\CopyrightPrinter; namespace StaticMapLite\CopyrightPrinter;
use Imagine\Gd\Imagine;
use Imagine\Image\Point;
use StaticMapLite\Canvas\CanvasInterface; use StaticMapLite\Canvas\CanvasInterface;
class CopyrightPrinter implements CopyrightPrinterInterface class CopyrightPrinter implements CopyrightPrinterInterface
{ {
/** @var string $osmLogo */ /** @var string $copyrightPath */
protected $osmLogo = '../images/osm_logo.png'; protected $copyrightPath = '../images/osm_logo.png';
/** @var CanvasInterface $canvas */ /** @var CanvasInterface $canvas */
protected $canvas; protected $canvas;
@ -21,21 +23,12 @@ class CopyrightPrinter implements CopyrightPrinterInterface
public function printCopyright(): CopyrightPrinterInterface public function printCopyright(): CopyrightPrinterInterface
{ {
$logo = imagecreatefrompng($this->osmLogo); $imagine = new Imagine();
$copyrightImage = $imagine->open($this->copyrightPath);
$logoWidth = imagesx($logo); $point = new Point(0,0);
$logoHeight = imagesy($logo);
imagecopy( $this->canvas->getImage()->paste($copyrightImage, $point);
$this->canvas->getImage(),
$logo,
imagesx($this->canvas->getImage()) - $logoWidth,
imagesy($this->canvas->getImage()) - $logoHeight,
0,
0,
$logoWidth,
$logoHeight
);
return $this; return $this;
} }