How do I resize and convert an uploaded image to a PNG using GD?
问题 I want to allow users to upload avatar-type images in a variety of formats ( GIF, JPEG, and PNG at least ), but to save them all as PNG database BLOBs . If the images are oversized, pixelwise, I want to resize them before DB-insertion. What is the best way to use GD to do the resizing and PNG conversion? Edit: Sadly, only GD is available on the server I need to use, no ImageMagick. 回答1: <?php /* Resizes an image and converts it to PNG returning the PNG data as a string */ function imageToPng(