PHP | imagecopymerge() Function (original) (raw)
Last Updated : 11 Jul, 2025
The **imagecopymerge() function is an inbuilt function in PHP that is used to copy and merge the image into a single image. This function returns True on success or False on failure.
**Syntax:
_bool imagecopymerge ( dstimage,dst_image, dstimage,src_image, dstx,dst_x, dstx,dst_y, srcx,src_x, srcx,src_y, srcw,src_w, srcw,src_h, $pct )
**Parameters: This function accepts nine parameters, as mentioned above and described below:
- ****$dst_image:** This parameter is used to set the destination image link resource.
- ****$src_image:** This parameter is used to set the source image link resource.
- ****$dst_x:** This parameter is used to set the x-coordinate of the destination point.
- ****$dst_y:** This parameter is used to set the y-coordinate of the destination point.
- ****$src_x:** This parameter is used to set the x-coordinate of the source point.
- ****$src_y:** This parameter is used to set the y-coordinate of the source point.
- ****$src_w:** This parameter is used to set the source width.
- ****$src_h:** This parameter is used to set the source height.
- ****$pct:** The two images will be merged with the help of _$pct variables. The range of PCT is 0 to 100. If pct=0,thennoactionistaken,andwhenpct = 0, then no action is taken, and when pct=0,thennoactionistaken,andwhenpct = 100, then this function behaves similarly to the imagecopy() function for palette images, except ignoring the alpha components. It implements alpha transparency for true color images.
**Return Value: This function returns True on success or False on failure. The below programs illustrate the **imagecopymerge() function in PHP.
**Program 1: **Input Source Image:
**Input Destination Image:
php `
`
**Output:

**Program 2: **Input Source Image:

**Input Destination Image:
php `
`
**Output:

**Related Articles:
- PHP | imagecolorclosestalpha() Function
- PHP | imagecolorallocatealpha() Function
- PHP | imagecolorallocate() Function
**Reference: https://www.php.net/manual/en/function.imagecopymerge.php