I am running a site off of BlueHost, with PHP 5.4
, and GD Version bundled (2.0.34 compatible)
- a high enough GD to use imagecreatetruecolor()
I am cropping an image, and sometimes the cropped image does not entirely fill the output thumb. imagecreatetruecolor()
leaves it with a black background wherever the resampled image isn't covering the output thumb, as shown below
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 am not having an issue with resampling the image, or using imagecreatetruecolor()
, but for whatever reason, I cannot get the background color to white.
Thank you in advance.
EDIT
If I comment out the line
imagecopyresampled(...)
then it gives the correct background color that I set in imagecolorallocate
and image fill
. It's the imagecopyresampled
that's causing the problem.