public function merge(
        Image $srcImage,
        $dstX,
        $dstY,
        $strategy = self::MERGE_SCALE_SRC
    ) {
        if (!is_resource($this->image) || !is_resource($srcImage->image)) {
            throw new \RuntimeException(
                'Attempt to merge image data using an invalid image resource.'
            );
        }

        // determine re-sampling strategy
        switch ($strategy) {
            // merge using the destination image dimensions
            case self::MERGE_SCALE_DST:
                $dstWidth = $this->width;
                $dstHeight = $this->height;

                break;

            // merge using the destination image dimensions, do not upscale
            case self::MERGE_SCALE_DST_NO_UPSCALE:
                $dstWidth = $this->width;
                if ($dstWidth > $srcImage->width) {
                    $dstWidth = $srcImage->width;
                }

                $dstHeight = $this->height;
                if ($dstHeight > $srcImage->height) {
                    $dstHeight = $srcImage->height;
                }

                break;

            // merge using the source image dimensions
            case self::MERGE_SCALE_SRC:
            default:
                $dstWidth = $srcImage->width;
                $dstHeight = $srcImage->height;
        }

        // copy images around
        @imagecopyresampled(
            $this->image,
            $srcImage->image,
            (int)$dstX,
            (int)$dstY,
            0,
            0,
            (int)$dstWidth,
            (int)$dstHeight,
            $srcImage->width,
            $srcImage->height
        );

        return $this;
    }
public function merge(
        Image $srcImage,
        $dstX,
        $dstY,
        $strategy = self::MERGE_SCALE_SRC
    ) {
        if (!is_resource($this->image) || !is_resource($srcImage->image)) {
            throw new \RuntimeException(
                'Attempt to merge image data using an invalid image resource.'
            );
        }

        // determine re-sampling strategy
        switch ($strategy) {
            // merge using the destination image dimensions
            case self::MERGE_SCALE_DST:
                $dstWidth = $this->width;
                $dstHeight = $this->height;

                break;

            // merge using the destination image dimensions, do not upscale
            case self::MERGE_SCALE_DST_NO_UPSCALE:
                $dstWidth = $this->width;
                if ($dstWidth > $srcImage->width) {
                    $dstWidth = $srcImage->width;
                }

                $dstHeight = $this->height;
                if ($dstHeight > $srcImage->height) {
                    $dstHeight = $srcImage->height;
                }

                break;

            // merge using the source image dimensions
            case self::MERGE_SCALE_SRC:
            default:
                $dstWidth = $srcImage->width;
                $dstHeight = $srcImage->height;
        }

        // copy images around
        @imagecopyresampled(
            $this->image,
            $srcImage->image,
            (int)$dstX,
            (int)$dstY,
            0,
            0,
            (int)$dstWidth,
            (int)$dstHeight,
            $srcImage->width,
            $srcImage->height
        );

        return $this;
    }
public function merge ( Image $ srcImage , $ dstX , $ dstY , $ strategy = self :: MERGE_SCALE_SRC ) { if ( ! is_resource ( $ this -> image ) || ! is_resource ( $ srcImage -> image ) ) { throw new \ RuntimeException ( 'Attempt to merge image data using an invalid image resource.' ) ; } // determine re-sampling strategy switch ( $ strategy ) { // merge using the destination image dimensions case self :: MERGE_SCALE_DST : $ dstWidth = $ this -> width ; $ dstHeight = $ this -> height ; break ; // merge using the destination image dimensions, do not upscale case self :: MERGE_SCALE_DST_NO_UPSCALE : $ dstWidth = $ this -> width ; if ( $ dstWidth > $ srcImage -> width ) { $ dstWidth = $ srcImage -> width ; } $ dstHeight = $ this -> height ; if ( $ dstHeight > $ srcImage -> height ) { $ dstHeight = $ srcImage -> height ; } break ; // merge using the source image dimensions case self :: MERGE_SCALE_SRC : default : $ dstWidth = $ srcImage -> width ; $ dstHeight = $ srcImage -> height ; } // copy images around @ imagecopyresampled ( $ this -> image , $ srcImage -> image , ( int ) $ dstX , ( int ) $ dstY , 0 , 0 , ( int ) $ dstWidth , ( int ) $ dstHeight , $ srcImage -> width , $ srcImage -> height ) ; return $ this ; }
Copies the given Image image stream into the image stream of the active
instance using a scaling strategy.

@param Image $srcImage The source image.
@param int   $dstX     x-coordinate of destination point.
@param int   $dstY     y-coordinate of destination point.
@param int   $strategy Scaling strategy. Default: self::MERGE_SCALE_SRC

@return $this

@throws \RuntimeException Thrown if $this->image or $srcImage->image is
not a valid image resource.
Copies the given Image image stream into the image stream of the active instance using a scaling strategy .