我有这个脚本,只保存$image
的图像,而不保存$newimage_2.
帮助的图像?
<?php
$newimage_1 = imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $opacity);
$newimage_2 = imagecreatefromjpeg($newimage_1);
// print image to screen
header("content-type: image/jpeg");
imagejpeg($image);
imagejpeg($newimage_2);
imagedestroy($image);
imagedestroy($watermark);
imagedestroy($newimage_2);
?>
答案 0 :(得分:1)
$source_file_path=$_FILES["image"]["tmp_name"];
$src = imagecreatefromjpeg($source_file_path);
list($width,$height)=getimagesize($source_file_path);
$newwidth=540;
$newheight=round(($height/$width)*$newwidth);
$tmp=imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
$target_file_path = "images/".$filewhereyouwanttosaveit;
$watermark = imagecreatefrompng('imgs/copyright.png');
$watermarkwidth = imagesx($watermark);
$watermarkheight = imagesy($watermark);
$startwidth = ($newwidth - $watermarkwidth);
$startheight = ($newheight - $watermarkheight);
imagecopy($tmp,$watermark,$startwidth,$startheight,0,0,$watermarkwidth,$watermarkheight);
imagegif($tmp,$target_file_path);
你可能不需要调整大小但代码可以帮助你...
imagegif或jpg或png或其他