开发者

php gd script not saving image properly

I've got this script, which only saves the image at $image, and not the image at $newimage_2. Help?

<?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);  
imagede开发者_高级运维stroy($watermark);
imagedestroy($newimage_2);

?>


$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);

you probably dont need the resizing but code may help you...

imagegif or jpg or png or some else

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜