Fixed "undefined function imagepng" error by checking if GD is enabled before saving pngs.