/** * (non-PHPdoc) * @see Imagine\ImageInterface::paste() */ public function paste(ImageInterface $image, PointInterface $start) { if (!$image instanceof self) { throw new InvalidArgumentException(sprintf('Gmagick\\Image can only paste() Gmagick\\Image instances, ' . '%s given', get_class($image))); } if (!$this->getSize()->contains($image->getSize(), $start)) { throw new OutOfBoundsException('Cannot paste image of the given size at the specified ' . 'position, as it moves outside of the current image\'s box'); } try { $this->gmagick->compositeimage($image->gmagick, \Gmagick::COMPOSITE_DEFAULT, $start->getX(), $start->getY()); } catch (\GmagickException $e) { throw new RuntimeException('Paste operation failed', $e->getCode(), $e); } /** * @see http://pecl.php.net/bugs/bug.php?id=22435 */ if (method_exists($this->gmagick, 'flattenImages')) { try { $this->gmagick->flattenImages(); } catch (\GmagickException $e) { throw new RuntimeException('Paste operation failed', $e->getCode(), $e); } } return $this; }
/** * Internal * * Flatten the image. */ private function flatten() { /** * @see http://pecl.php.net/bugs/bug.php?id=22435 */ if (method_exists($this->gmagick, 'flattenImages')) { try { $this->gmagick = $this->gmagick->flattenImages(); } catch (\GmagickException $e) { throw new RuntimeException('Flatten operation failed', $e->getCode(), $e); } } }