Difference between "imagecopy ()" and "imagecopymerge ()"?

What is the difference between these two functions from the PHP GD library?

+6
source share
3 answers

These two functions are very similar to each other because they copy one image to another.

The way these functions differ is in the last parameter: imagecopy() always overwrites all the pixels in the destination with those at the source, while imagecopymerge() combines the destination pixels with the original pixels for the amount specified in the additional parameter:

 0 means "keep the source picture fully", 100 means "overwrite with the source picture fully", and 50 means "mix the source and destination pixel colours equally". 

Thus, the function imagecopy() equivalent to calling imagecopymerge() and passes 100 as the last parameter.

+14
source

The difference lies in the last parameter of $pct :

pct

The two images will be combined in accordance with pct, which can vary from 0 to 100. When pct = 0, no action is taken when 100 this function behaves the same as imagecopy () for images in the palette, while it implements alpha transparency for true color images.

It's about transparently blending two images together with just copying.

+3
source

imagecopymerge See pct argument description

The two images will be merged according to pct, which can vary from 0 to 100. When pct = 0, no action is taken when 100 this function behaves the same as imagecopy () for images in the palette, except for ignoring alpha components. while it implements alpha transparency for true color images.

+1
source

All Articles