Pay for Hesitation: [php]imagnepng的bug

Pages

2008年3月16日 星期日

[php]imagnepng的bug

一開始只看manual, 沒有注意到下面的comment,
imagepng($dest,$src,100);
一直無法成功..
才發現這個函數有bug...
要改成imagepgn($des, $src, 0, null);
第三個參數要為零, 且最後一個option參數一定要加上.

reference:
http://tw.php.net/imagepng

Jeff Sauro
14-Nov-2007 07:39
My webserver, running 5.14 didn't like the header that was generated using imagepng(). It works find on my local test server and on 4.x from another host.

The generated image displays in the browser (IE, firefox) but when saved to a file or inserted into an RTF file, the image was corrupted. As a test, when attempting to right-click to save as, the image format was not recognized.

The only work-around appears to be adding the additional paramaters.

So instead of just
imagepng($image); //DIDNT WORK--CORUPT IMAGE

This worked
imagepng($image,NULL,0,NULL);

and saving to disk, this worked:
imagepng($image,$file_location,0,NULL);

Jeff

沒有留言: