Php 向Ajax裁剪添加水印
我正在使用来自的Ajax裁剪,我想在脚本中添加一个水印。下面是我的脚本 水印Php 向Ajax裁剪添加水印,php,jquery,image-processing,gd,image-uploading,Php,Jquery,Image Processing,Gd,Image Uploading,我正在使用来自的Ajax裁剪,我想在脚本中添加一个水印。下面是我的脚本 水印 $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;
$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;
}
上传并调整部件大小
function resizeThumb($arr){
$date = md5(time());
$arr['temp_uploadfile'] = $arr['img_src'];
$arr['new_uploadfile'] = $arr['uploaddir'].strtolower($date).'.jpg';
asidoImg($arr);
exit;
}
我试着加上
$arr=水印图像($arr['temp\u uploadfile'],
$arr['uploaddir'].strtolower($date)。'.jpg')
代替
$arr['new_uploadfile']=$arr['uploaddir'].strtolower($date)。'.jpg'
但这不起作用
有人能帮我吗
下载和脚本使用ASIDO,并且它有一个内置的水印工具。 在func.php中,我完成了以下操作
function asidoImg2($arr){
include('asido/class.asido.php');
asido::driver('gd');
$height = $arr['height'];
$width = $arr['width'];
$x = $arr['x'];
$y = $arr['y'];
// process
$i1 = asido::image($arr['temp_uploadfile'], $arr['new_uploadfile']);
// fit and add white frame
if($arr['thumb'] === true){
Asido::Crop($i1, $x, $y, $width, $height);
asido::watermark($i1, 'watermark.png', ASIDO_WATERMARK_MIDDLE_LEFT, ASIDO_WATERMARK_SCALABLE_ENABLED, 1);
}
else{
Asido::Frame($i1, $width, $height, Asido::Color(255, 255, 255));
asido::watermark($i1, 'watermark.png', ASIDO_WATERMARK_MIDDLE_LEFT, ASIDO_WATERMARK_SCALABLE_ENABLED, 1);
}
// always convert to jpg
Asido::convert($i1, 'image/jpg');
$i1->Save(ASIDO_OVERWRITE_ENABLED);
$data = array(
'photo'=> $arr['new_uploadfile']
);
// echo $user_id;
// delete old file
echo $data['photo'];
}
怎么搞的?有什么错误吗?没有上传,也没有错误。似乎php失败了您应该阅读并放置
错误报告(E_ALL)代码>位于脚本顶部。这将让您看到错误。我放置了错误报告,但根本无法让它正常工作。不回显任何错误。请检查我对链接的编辑表示:md5(time())
文件名不是很好(=唯一)