This PHP function copies one image on to another and merges them to whatever parameter you assign. There are 9 parameters in all. |
1 | The destination image your copying to. |
2 | The source image your copying from. |
3 | The X coordinate you want to copy to on destination. |
4 | The Y coordinate you want to copy to. Area on destination image. |
5 | The X coordinate you want to copy from. Area of source image. |
6 | The Y coordinate you want to copy from. Area of source image. |
7 | The width of the source image you want to copy. Bottom right corner. |
8 | The height of the source image you want to copy. Bottom right corner. |
9 | The merge amount. 0=none. Source image remains intact. 100=all Overwrite source picture fully. 50=merge. Mix colors equally. |
The command looks like this:
imagecopymerge($destination, $source, 0, 0, 0, 0, 300, 300, 50); |
To test this command I created two gradient images from the gradient codes Sally has provided. The first one is a horizontal gradient jpg, 300x300. Click on image to enlarge. | |
Here is the php code that I used to do this: |
Next I made another gradient using the rotated version of the first. Again a 300x300 jpg. | |
Here is the PHP text for that. |
Next I merged these two images and got this. | |
Here is the PHP script to get that image. |
Then I took that image and used it as a Tile to fill a circle and got this. | |
Here is the PHP script to do that. |
In order to tile the circle you do need a Tile that is equal or larger than the circle it is intended to tile or you will get some black lines where the image repeats its tiling. If you want a copy of all these files they can be found in this zip file. If you just want the imagecopymerge file just CCP this TEXT and change it to php: ZIP download |
I played around with the following images to get some idea of what is possible and how the parameters work. I used two images. |
| |
For the parameters, the first two numbers are the x,y on the background image where you want to begin the merge. The second two numbers are the x,y of the top image. The third set of x,y numbers are the lower x,y of the top image. (regardless of where I want it to fall on the background, it's just the size of the smaller image). The last number is color merge (0-100). |
The first image was done with a png circle which did not show the color of the heart at all. So I changed to a gif circle and got the second image. |
| |
The circle is 300x300. The heart is 200x200. Used these parameters: imagecopymerge($circle, $heart, 50, 50, 0, 0, 200, 200, 50) |
Then I did some multiple heart merges and got these images. |
| |
TXT File | TXT File |