PHP imagecolorallocate not working

I am running a BlueHost site with PHP 5.4

and GD Version bundled (2.0.34 compatible)

- high enough GD to useimagecreatetruecolor()

I crop the image and sometimes the cropped image does not completely fill the output finger. imagecreatetruecolor()

leaves it on a black background wherever the resized image does not cover the output finger as shown below

Thumb, with black background

but I would like it to be a WHITE or TRANSPARENT background.

PHP:

$tci = imagecreatetruecolor($w, $h);

$color = imagecolorallocate($tci, 255, 255, 255);
imagefill($tci, 0, 0, $color);

imagecopyresampled($tci, $img, 0, 0, $x, $y, $w, $h, $wOr, $hOr);
imagejpeg($tci, $preview, $qual);

      

I have no problem resampling the image or using imagecreatetruecolor()

, but for some reason I can't get the background color to white.

Thanks in advance.

EDIT

If I comment out the line

imagecopyresampled(...)

      

then it gives the correct background color which I set to imagecolorallocate

and image fill

. This is the problem imagecopyresampled

causing the problem.

+3


source to share





All Articles