public function place(IImageAdapter $image, $left = 0, $top = 0, $opacity = 100) { $opacity = max(0, min(100, (int) $opacity)); if (substr($left, -1) === '%') { $left = round(($this->getWidth() - $image->getWidth()) / 100 * $left); } if (substr($top, -1) === '%') { $top = round(($this->getHeight() - $image->getHeight()) / 100 * $top); } if ($opacity === 100) { imagecopy($this->getImageResource(), $image->getImageResource(), $left, $top, 0, 0, $image->getWidth(), $image->getHeight()); } elseif ($opacity != 0) { imagecopymerge($this->getImageResource(), $image->getImageResource(), $left, $top, 0, 0, $image->getWidth(), $image->getHeight(), $opacity); } return $this; }
public function place(IImageAdapter $image, $left = 0, $top = 0, $opacity = 100) { $opacity = max(0, min(100, (int) $opacity)); if (substr($left, -1) === '%') { $left = round(($this->getWidth() - $image->getWidth()) / 100 * $left); } if (substr($top, -1) === '%') { $top = round(($this->getHeight() - $image->getHeight()) / 100 * $top); } //$image->getImageResource()->setImageOpacity($opacity / 100); $this->getImageResource()->evaluateImage(Imagick::EVALUATE_MULTIPLY, $opacity / 100, Imagick::CHANNEL_ALPHA); $this->getImageResource()->compositeImage($image->getImageResource(), Imagick::COMPOSITE_OVER, $left, $top); return $this; }