At 12:16 PM -0400 5/6/08, Travis L. Font wrote:
Following files:
bg.png - Clear Transparent Image
14416fed5d4f78.jpg - Normal Jpeg Image
The Code:
header('content-type: image/png');
$watermark = imagecreatefromjpeg('14416fed5d4f78.jpg');
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
$image = imagecreatetruecolor($watermark_width, $watermark_height);
$image = imagecreatefrompng('bg.png');
$size = getimagesize('bg.png');
$dest_x = $size[0] - $watermark_width - 5;
$dest_y = $size[1] - $watermark_height - 5;
imagecopymerge($image, $watermark, $dest_x,
$dest_y, 0, 0, $watermark_width,
$watermark_height, 100);
imagepng($image);
imagedestroy($image);
imagedestroy($watermark);
The Problem:
The code above works fine in sense of syntax!
bg.png acts as a transparent border for
14416fed5d4f78.jpg to keep the size of bg.png
and not the size of 14416fed5d4f78.jpg so it
doesn't blow up 14416fed5d4f78.jpg. However, the
image comes out black/white and has lost its
color!
I looked all over Google and I've found nothing
so far that's functional to give the new created
png file the correct colors as the original
14416fed5d4f78.jpg. I figure that I'm missing
some small elements to the process of creating
the png?
Anyone have any ideas, pointers, advice, or
correct solution to make this possible?
Travis:
Try this:
$original=imagecreatefromjpeg("mydog.jpg");
$watermark=imagecreatefrompng("copyright.png");
$osx=imagesx($original);
$osy=imagesy($original);
$wsx=imagesx($watermark);
$wsy=imagesy($watermark);
imagecopy($original, $watermark, ($osx-$wsx)/2,
($osy-$wsy)/2, 0, 0, $wsx, $wsy); //center
imagepng($original, "trans.png");
The code works here:
http://webbytedd.com/b/watermark/
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com