Forum Moderators: coopster

Message Too Old, No Replies

gd makes my image pure white

         

bleak26

12:04 pm on Feb 15, 2006 (gmt 0)

10+ Year Member



I am trying to create a timeline image but the image I am using as a watermark seems to become just a white space when i use ImageCreateFromPNG. If I use imagecreatefromjpeg I get a black space. Can anyone tell me why this is randomly happening? I have tried different values for the pct as this seems to work as transparency, but I have never actually seen anything more than the shape of my image and the blackness or whiteness.

<?php
// set up image
$height = 600;
$width = 656;
$im = ImageCreateTrueColor($width, $height);
$white = ImageColorAllocate ($im, 255, 255, 255);
$blue = ImageColorAllocate ($im, 0, 0, 64);

// draw on image
ImageFill($im, 0, 0, $white);
ImageLine($im, 328, 40, 328,$height, $blue);
ImageString($im, 4, 50, 153, 'Tom\'s first birthday', $blue);
ImageString($im, 4, 260, 10, 'Date of birth 1978', $blue);

ImageString($im, 4, 50, 133, '14/06/1979', $blue);
ImageLine($im, 50, 150, 328,150, $blue);
//watermark image dimensions are width 200, height 91
$watermark = ImageCreateFromPNG("watermark.png");
($im,$watermark,100,100,200,91,200,91,100);

// output image
Header ('Content-type: image/png');
ImagePng ($im);

ImageDestroy($im);
ImageDestroy($watermark);
?>

coopster

10:49 pm on Feb 18, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Your line of code seems to be missing but since you are adding a watermark I'm guessing you are trying to merge the images.

bool imagecopymerge [php.net] ( resource dst_im, resource src_im, int dst_x, int dst_y, int src_x, int src_y, int src_w, int src_h, int pct )

Your problem is that you don't have the x and y coordinates of the source set correctly. Try this:

//watermark image dimensions are width 200, height 91 
$watermark = ImageCreateFromPNG("watermark.png");
imagecopymerge($im,$watermark,100,100,0,0,200,91,100);

That last parameter is the transparency, if you play with that now I think you will see you can make your watermark ... well, more transparent.