/** * Places an image on top of the current resource. If the width and height are supplied, will * perform a resize before placing the image. * * @param mixed $image Path to an image on filesystem or an Imanee Object. * @param int $place_constant One of the Imanee::IM_POS constants, defaults to * IM_POS_TOP_LEFT (top left corner). * @param int $width Width for the placement. * @param int $height Height for the placement. * @param int $transparency Transparency of the placed image - 0 (default) to 100 * (transparent). * * @return $this * * @throws UnsupportedMethodException * @throws UnsupportedFormatException */ public function placeImage($image, $place_constant = Imanee::IM_POS_TOP_LEFT, $width = null, $height = null, $transparency = 0) { if (!$this->resource instanceof ImageComposableInterface) { throw new UnsupportedMethodException("This method is not supported by the ImageResource in use."); } if (!is_object($image)) { $img = clone $this; $img->load($image); $image = $img; } if (!$image instanceof \Imanee\Imanee) { throw new UnsupportedFormatException('Object not supported. It must be an instance of Imanee'); } if ($width and $height) { $image->resize($width, $height); } list($coordX, $coordY) = PixelMath::getPlacementCoordinates($image->getSize(), ['width' => $this->getWidth(), 'height' => $this->getHeight()], $place_constant); $this->resource->compositeImage($image, $coordX, $coordY, 0, 0, $transparency); return $this; }