开发者

GD: php imagepng creates whitespace in image

I have some problem with GD when i creates images with php.

The strange thing is that it works on one server with php version 5.3.1 but not on php version 5.2.14. (I'm not sure if it's the php version or the GD lib that is doing this.)

GD: php imagepng creates whitespace in image

This file is created with convert and saved in a directory in captcha::get_file().

GD: php imagepng creates whitespace in image

And this file is generated with imagecreatefrompng() and imagepng()

GD: php imagepng creates whitespace in image

I made some small changes to the script and made a gif. But there is still a problem with the png

What causes this, and how can I fix it?

Here is the phpcode:

<?php
session_start();
require_once("./captcha.php"));    

// creates the image with convert and returns the location of the picture
// document_root/picture/picture.png
$picloc = captcha::get_file(); 

$image = @imagecreatefrompng($picloc); 

header('Content-type: image/png');

imagepng($image);

imagedestroy($image);

unlink($picloc);
?&开发者_运维问答gt;


not positive, but the problem may be in your content length header.

header('Content-Length: ' . strlen($image));

at this point in your code, $image is a resource data type, not a string. try simply removing the content-length header line, and see what happens.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜