public function resize(Size $size) { $dst_img = new EmptyLayer($size->getWidth(), $size->getHeight()); imagecopyresampled($dst_img->getResource(), $this->resource, 0, 0, 0, 0, $size->getWidth(), $size->getHeight(), $this->getWidth(), $this->getHeight()); $this->resource = $dst_img->getResource(); $this->width = $size->getWidth(); $this->height = $size->getHeight(); }
public function __construct($fontFile, $fontSize, Color $color, $text) { $boxSize = imagettfbbox($fontSize, 0, $fontFile, $text); $width = $boxSize[4] - $boxSize[6]; $height = $boxSize[1] - $boxSize[7]; parent::__construct($width, $height, true); $color = imagecolorallocate($this->resource, $color->getR(), $color->getG(), $color->getB()); imagettftext($this->resource, $fontSize, 0, 0, $this->height, $color, $fontFile, $text); }