I am resizing PNG images using the GD image library function ImageCopyResampled(). It all works fine, I can even keep alpha blending transparency with the use of ImageCreateTrue
With imagecreate()
you're creating an indexed-color PNG file and with imagecreatetruecolor()
you're creating a 24-bit color PNG file. Of course the resampling quality is going to appear much better with the true color image, since it has a much larger range of colors to use when resampling. With imagecreate()
, the system can only use the much smaller palette.
You can try this out using Photoshop or Gimp, scaling images in the different color modes (indexed and RGB). Unfortunately it's the nature of the game-- the file size will be larger when there are more colors to store.
I'm not sure if it would make a difference, but you could try using imagecopyresampled()
to copy to a true-color resource (from imagecreatetruecolor()
), then copy (but not resample) that to a palette image resource. This way the palette is determined based on the resampled result. I'm not sure that you'd be able to retain the alpha channel, though.