I'm pretty sure I need to use imagefilledrectangle in order to get a white background instead of black on this... just not sure how. I've tried a few ways.
$targetImage = imagecreatetruecolor($thumbw,$thumbh);
imagecopyresized($targetImage,$sourceImage,0,0,0,0,$thumbWidth,$thumbHeight,imagesx($sourceImage),imagesy($sourceImage));
The imagecolortransparent() function is an inbuilt function in PHP which is used to define color as transparent. It sets the color of a transparent image. It returns the identifier of the new transparent color. If an image has no transparent color and color not specified then it returns -1.
$image = imagecreatetruecolor(500, 300); // Set the background color of image. $bg = imagecolorallocate( $image , 205, 220, 200);
The imagecreatetruecolor() function is an inbuilt function in PHP which is used to create a new true-color image. This function returns a blank image of the given size.
The imagecolorallocate() function is an inbuilt function in PHP which is used to set the color in an image. This function returns a color which is given in RGB format. Syntax: int imagecolorallocate ( $image, $red, $green, $blue )
UPDATE (2020): Please see this answer below for a faster fill than imagefill: https://stackoverflow.com/a/32580839/1005039
ORIGINAL
From the PHP manual entry for imagefill:
$image = imagecreatetruecolor(100, 100);
// set background to white
$white = imagecolorallocate($image, 255, 255, 255);
imagefill($image, 0, 0, $white);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With