/** * Flood the image with a color fill. * * @param int $r * @param int $g * @param int $b * @return Gmagick */ public function fill($r, $g, $b) { $draw = new \GmagickDraw(); $draw->setFillColor($this->image->getColor([(int) $r, (int) $g, (int) $b])); $draw->rectangle(0, 0, $this->image->getWidth(), $this->image->getHeight()); $this->image->resource()->drawImage($draw); return $this; }
/** * Draw a rectangle on the image. * * @param int $x * @param int $y * @param int $w * @param int $h * @return Gmagick */ public function rectangle($x, $y, $w, $h = null) { $x2 = $x + $w; $y2 = $y + (null === $h ? $w : $h); $draw = new \GmagickDraw(); if (null !== $this->fillColor) { $draw->setFillColor($this->image->getColor($this->fillColor, $this->opacity)); } if ($this->strokeWidth > 0) { $draw->setStrokeColor($this->image->getColor($this->strokeColor, $this->opacity)); $draw->setStrokeWidth($this->strokeWidth); } $draw->rectangle($x, $y, $x2, $y2); $this->image->resource()->drawImage($draw); return $this; }
private function drawRectangleAndReplaceExistImg($image, $height, $width) { // прямоугольник рисуем снизу изображения высотой 8% от высоты изображения $heightRectagle = $height * 0.08; $gmagicDraw = new GmagickDraw(); $gmagicDraw->setfillcolor("#fff"); $gmagicDraw->rectangle(0, $height - $heightRectagle, $width, $height); $gImage = new Gmagick(); $gImage->readImage($image); $gImage->drawimage($gmagicDraw); $gImage->writeimage($image); $gImage->destroy(); }