make your post harder to understand for non native english speakers
Sorry - so many of the non-English natives on this site use such good English that it is very, very easy to forget it's not your native tongue.
you never set $resize background to white!
No I don't. Why would I?
$resize contains the picture, not the background. Setting the background of the picture turns it white which is not what I want.
Thanks for the working example. It reinforces that I am (probaly) approaching the problem the right way. However, when I plug in a picture instead of a pattern build in GD it reverts to not setting the background. It seems to be a problem with actual pictures. Connecting that with what afoken has suggested, it seems likely that it is to do with the colour palette of the picture.