0
我使用Ajax作物從enter link description here我想爲該腳本添加水印。以下是我的腳本。將水印添加到Ajax作物
WATERMARK
$image_path = "watermark.png";
function watermark_image($oldimage_name, $new_image_name){
global $image_path;
list($owidth,$oheight) = getimagesize($oldimage_name);
$width = 500; $height = 100;
$im = imagecreatetruecolor($width, $height);
$img_src = imagecreatefromjpeg($oldimage_name);
imagecopyresampled($im, $img_src, 0, 0, 0, 0, $width, $height, $owidth, $oheight);
$watermark = imagecreatefrompng($image_path);
list($w_width, $w_height) = getimagesize($image_path);
$pos_x = $width - $w_width;
$pos_y = $height - $w_height;
imagecopy($im, $watermark, $pos_x, $pos_y, 0, 0, $w_width, $w_height);
imagejpeg($im, $new_image_name, 100);
imagedestroy($im);
unlink($oldimage_name);
return true;
}
UPLOAD和調整PART
function resizeThumb($arr){
$date = md5(time());
$arr['temp_uploadfile'] = $arr['img_src'];
$arr['new_uploadfile'] = $arr['uploaddir'].strtolower($date).'.jpg';
asidoImg($arr);
exit;
}
我嘗試添加
$ ARR = watermark_image($ ARR [ 'temp_uploadfile'], $改編[ 'uploaddir']。ST 。rtolower($日期) 'JPG');
代替
$ ARR [ 'new_uploadfile'] = $ ARR [ 'uploaddir']用strtolower($日期) 'JPG'。。。;
但這沒有奏效。
有人可以幫助我嗎?
發生了什麼事?有沒有錯誤? – 2012-07-17 12:26:32
沒有上傳,也沒有錯誤。似乎PHP失敗 – ngplayground 2012-07-17 12:36:44
你應該閱讀http://stackoverflow.com/tags/php/info,並在腳本的頂部放置'error_reporting(E_ALL);'。這會讓你看到錯誤。 – 2012-07-17 13:06:05