note 100098 modified in function.imagecopymerge by danbrown
| From: | danbrown@php.net | Date: | Sat, 08 Jan 2011 16:58:23 +0000 |
| Subject: | note 100098 modified in function.imagecopymerge by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-175536@lists.php.net to get a copy of this message | ||
TO merge two images with alpha - use a brush to draw a zero length line in the centre of the target
image, using the src img as the brush img. The code probably explains it better:
<?php
$src = imagecreatefromstring(file_get_contents("location of src"));
$dest = imagecreatefromstring(file_get_contents("location of dest"));
// Set the brush
imagesetbrush($dest, $src);
// Draw a couple of brushes, each overlaying each
imageline($dest, imagesx($dest) / 2, imagesy($dest) / 2, imagesx($dest) / 2, imagesy($dest) / 2,
IMG_COLOR_BRUSHED);
header('Content-Type: image/png');
imagepng($dest);
?>
This is simple and has reasonable performance.
--was--
TO merge two images with alpha - use a brush to draw a zero length line in the centre of the target
image, using the src img as the brush img. The code probably explains it better:
$src = imagecreatefromstring(file_get_contents("location of src"));
$dest = imagecreatefromstring(file_get_contents("location of dest"));
// Set the brush
imagesetbrush($dest, $src);
// Draw a couple of brushes, each overlaying each
imageline($dest, imagesx($dest) / 2, imagesy($dest) / 2, imagesx($dest) / 2, imagesy($dest) / 2,
IMG_COLOR_BRUSHED);
header('Content-Type: image/png');
imagepng($dest);
This is simple and has reasonable performance.
http://php.net/manual/en/function.imagecopymerge.php