PHP图像调整大小只返回黑色背景。图像调整大小返回黑色背景
我在这里阅读所有类似的帖子,但没有一个解决了我的问题。
下面是代码:
$namef = $_FILES['image']['name'];
$tmp_name = $_FILES['image']['tmp_name'];
$src = imagecreatefromjpeg($tmp_name);
$location = "../userpictures/standard/".$mdid.".".$mzad;
move_uploaded_file($tmp_name, $location);
list($width, $height, $type, $att) = getimagesize($location);
$newwidth = 200;
$newheight=($height/$width)*$newwidth;
$tmp=imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,
$width,$height);
$locations = "../userpictures/medium/".$mdid.".".$mzad;
imagejpeg($tmp,$locations,100);
move_uploaded_file($tmp_name, $location);
我检查这些代码是否是在PHP教程有效,这是确定的代码。
你有一个黑色背景的gif文件与透明度,但jpgs罚款? – Cheery 2012-02-06 19:45:57
我不允许使用gif文件。只有jpg。所以jpg没有透明度 – 2012-02-06 19:46:36