Tôi đã thực hiện một chức năng để xử lý các tệp jpg và png, nhưng tôi gặp lỗi khi cố tải lên tệp png.tạo các tệp png
này là chức năng:
function createImg ($type, $src, $dst, $width, $height, $quality) {
$newImage = imagecreatetruecolor($width,$height);
if ($type == "jpg/jpeg") {
//imagecreatefromjpeg() returns an image identifier representing the image obtained from the given filename.
$source = imagecreatefromjpeg($src);
}
else if ($type == "png") {
//imagecreatefrompng() returns an image identifier representing the image obtained from the given filename.
$source = imagecreatefrompng($src);
}
imagecopyresampled($newImage,$source,0,0,0,0,$width,$height,getWidth($src),getHeight($src));
if ($type == "jpg/jpeg") {
//imagejpeg() creates a JPEG file from the given image.
imagejpeg($newImage,$dst,$quality);
}
else if ($type == "png") {
//imagepng() creates a PNG file from the given image.
imagepng($newImage,$dst,$quality);
}
return $dst;
}
tác phẩm như mong muốn với jpg, png, nhưng với tôi nhận được msg lỗi này:
Cảnh báo: imagepng() [function.imagepng ]: gd-png: lỗi libpng gây tử vong: zlib không thể khởi chạy lỗi máy nén - luồng trong E: ... \ php \ functions.upload.php trên dòng 48
Cảnh báo: imagepng() [function.imagepng] : lỗi gd-png: setjmp trả về tình trạng lỗi trong E: ... \ php \ functions.upload.php trên đường dây 48
EDIT:
tôi chỉ cần thay đổi loại bỏ các imagepng(); và chỉ sử dụng imagejpeg và nó hoạt động như thế này, tôi chỉ muốn lưu các tập tin jpg anyways. cảm ơn!
whats on line 48 –