查看图片路径是否正确
地址写错了把 ?
什么白色变黑色,你的图片是PNG格式的吧 水印图片背景本来是透明的,把水印图片加上去后 背景变为黑色
imagecopy() 能实现png格式图片(透明的背景),但不能实现图片的淡化。
imagecopymerge() 使用alpha透明度可以实现图片的淡化 (如:30),但是水印图片(png格式)的透明背景会默认为黑色,并且有白边出现。如果想让图片又是透明背景又可以淡化 @我吧 哈哈哈哈
imagecopyresampled可能是参数写错
header('Content-type:'.$info['mime']);你少了冒号。
$src = "1.jpg";
$info = getimagesize($src);
$type = image_type_to_extension($info[2],false);
$fun = "imagecreatefrom{$type}";
$image = $fun($src);
$target = imagecreatetruecolor(300,300);
imagecopy($target,$image,0,0,0,0,300,300);
$image_thumb = imagecreatetruecolor(100,100);
imagecopyresampled($image_thumb,$image,0,0,0,0,100,100,$info[0],$info[1]);
imagedestroy($image);
$image = $image_thumb;
header("Content-type: image/jpeg");
$funs = "image{$type}";
$funs($image_thumb);
输出前加,ob_clean();
如果写成header('content_type:image/jpeg') 这样,就表示类型只能是图片类型,而且只能是jpeg格式的。
而写成header('content_type:'.$info['mime']),content_type是有上传的文件决定的,是可变的(如果是png图片就是image/png),更灵活!
第一种
$image_thumb = imagecreatetruecolor(300,200);将值改为80,80
第二种
imagecopyresampled($image_thumb,$image,0,0,0,0,80,80,$info[0],$info[1]);将80和80改为 300,200
http://php.net/get/php_manual_zh.chm/from/a/mirror 这是php中文手册 不懂的可以去下载来看
14行注释了怎么看到图。
你用的是火狐浏览器么,在页面中输出时这个样子的,如果你想要使用,应该是吧图片先用save方法把图片保存到硬盘中,然后如果你是html页面调用的话应该这样子<img src="你图片保存的路径">。
希望可以帮到你
同学方便把代码放上来么