PHP水印无法上载png
我的脚本它与jpg,jpeg,bmp工作时,我上传和成功。 但当我上传png、gif时,它会存储在我的文件夹中,但图像是空白的,背景颜色为黑色 有什么办法解决这个问题吗PHP水印无法上载png,php,png,jpeg,watermark,Php,Png,Jpeg,Watermark,我的脚本它与jpg,jpeg,bmp工作时,我上传和成功。 但当我上传png、gif时,它会存储在我的文件夹中,但图像是空白的,背景颜色为黑色 有什么办法解决这个问题吗 $water_mark_text_2 = "text"; $font_path = "fonts/BRLNSR.TTF"; $font_size = 25; // in pixcels //$water_mark_text_1 = "9"; function watermark_text($oldimage_nam
$water_mark_text_2 = "text";
$font_path = "fonts/BRLNSR.TTF";
$font_size = 25; // in pixcels
//$water_mark_text_1 = "9";
function watermark_text($oldimage_name, $new_image_name){
global $font_path, $font_size, $water_mark_text_1, $water_mark_text_2;
list($width,$height) = getimagesize($oldimage_name);
$image = imagecreate(100, 100);
// sets some colors
$white = imagecolorallocate($image, 255, 255, 255);
$black = imagecolorallocate($image, 0, 0, 0);
$image = imagecreatetruecolor($width, $height);
$image_src = imagecreatefromjpeg($oldimage_name);
imagecopyresampled($image, $image_src, 0, 0, 0, 0, $width, $height, $width, $height);
//imagecopyresampled($image, $stamp, $image_src, 0, 0, 0, 0, $width, $height, $width, $height , imagesx($stamp), imagesy($stamp), 60);
// $black = imagecolorallocate($image, 0, 0, 0);
$blue = imagecolorallocate($image, 79, 166, 185);
// imagettftext($image, $font_size, 0, 30, 190, $black, $font_path, $water_mark_text_1);
imagettftext($image, $font_size, 0, 5, 20, $white, $font_path, $water_mark_text_2);
imagejpeg($image, $new_image_name, 100);
imagedestroy($image);
unlink($oldimage_name);
return true;
}
$path = "$stored/";
$valid_formats = array("jpg", "bmp","jpeg","JPG","png");
$name = $_FILES['img']['name'];
list($txt, $ext) = explode(".", $name);
$upload_status = move_uploaded_file($_FILES['img']['tmp_name'],$path.$name);
$new_name = $stored.$md5_img.".jpg";
watermark_text($path.$_FILES['img']['name'], $new_name);
如果我将imagecreatefromjpeg更改为imagecreatefrompng,将imagejpg更改为imagepng。
图像仍在上传,但我无法打开。对于PNG图像,您应该使用我尝试过的,它存储在我的文件夹中。但是图像无法打开。im使用imagecreatefrompng()和imagepng