views:

1034

answers:

1

I'm using PHP 5 GD Lib to do some graphic manipulations, and I can't find a way to get around the black background that shows up when you rotate an image or copy an image to another (larger) image.

Assuming that I am working with a jpeg file, which of course is not transparent, how can I rotate the image using gd lib and end up with a white background / canvas, rather than black background?

+2  A: 

This comment is from the PHP documentation and credit goes to "weareexit at yahoo dot co dot uk"

"If you want to place an image on a larger canvas you've previously created with imagecreatetruecolor(), but you don't want the default black background to surround it: use imagefill() AFTER imagecopyresampled()."

Ólafur Waage
Thanks! I ended up doing an imagefill() from all 4 corners in order to "flood" the entire canvas.
Rafe