给gif动态图片添加水印,在线等!!! 给gif动态图片添加水印,是字体水印,不能改变原来的gif动态图片!!!!!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://s310191921.onlinehome.fr/cfstat/phptest.html 这是我自己搞的结果,大家帮忙看下吧 !!!$k = 15;$ar = array( array( 'filename' =>'frames/frame0.gif', 'top' => 0, 'left' => 0, 'action' => 1, 'time' => $k, ), array( 'filename' =>'frames/frame1.gif', 'top' => 0, 'left' => 0, 'action' => 2, 'time' => $k, ), );$gif = new TGifAnimation;//合并多张gif图片为一张gif图片$gif->parse($ar, $width, $height);<?phpinclude_once 'imac_ReadGif.php';class TGifAnimation { var $args_dict = array( 'filename', 'left', 'top', 'width', 'height', 'frame', 'action', 'time', ); var $source = array(); /** * 输出应用程序扩展段 **/ function application_extension() { printf("%c%c%cNETSCAPE2.0%c%c%c%c%c",0x21,0xff,11,3,1,0,0,0); } /** * 输出图象扩展控制段 **/ function control_extension(&$resources, $frame, $delay_time=10, $disposal_mothod=0) { $resources->control_extension($frame, $delay_time, $disposal_mothod); } /** * 输出一帧图象 **/ function image_frame(&$resources, $frame, $left, $top, $width, $height) { if($top >= 0 && $left >= 0 && ($width ==0 || $height == 0)) return $resources->image_frame($frame, $left, $top, $this->global_color_table); //当图象位置越出图片范围或需要调整图象大小时,执行以下代码 $width or $width = $resources->image[$frame]['width']; $height or $height = $resources->image[$frame]['height']; //取得原图透明色索引 $transparecy_index = $resources->image[$frame]['transparecy_index']; //导出原图图象 $buf = $resources->withdraw($frame); $sim = imagecreatefromstring($buf); $dim = imagecreate($width, $height); //复制原图调色板到目标图 imagepalettecopy($dim, $sim); imagefill($dim , 0, 0, $transparecy_index); imagecolortransparent($dim, $transparecy_index); //调整截取位置并复制原图到目标图 $x = $y = 0; if($left < 0) list($left, $x) = array($x, $left); if($top < 0) list($top, $y) = array($y, $top); imagecopyresized($dim, $sim, $x, $y, 0, 0, $width, $height, imagesx($sim), imagesy($sim)); //生成目标图片数据 ob_start(); imagegif($dim); ImageDestroy($sim); ImageDestroy($dim); $buf = ob_get_clean(); //从目标图片数据中提取图象 $t = new TGif($buf); $t->image_frame(0, $left, $top, $this->global_color_table); } /** * 输出图片头 **/ function image_header($width, $height) { ob_start(); $this->global_color_table = $this->source[0]['resources']->global_color_table; $flag = $this->source[0]['resources']->flag; printf("GIF89a%s%s%c%c%c", pack("S", $width), pack("S", $height), $flag, 0, 0); echo $this->global_color_table; } /** * 输出图片尾,并选择输出方向 **/ function image_end($filename) { echo chr(0x3b); $buf = ob_get_clean(); if(empty($filename)) { header("Content-type: image/gif"); echo $buf; //Imagegif($buf); //ImageDestroy($buf); }else file_put_contents($filename, $buf); } /** * 合成动画 * 参数 * $image 数组,必须有filename元素 * left 图象在图片中的左边距,默认为0 * top 图象在图片中的上边距,默认为0 * frame 若filename有多帧需要指明帧号(第一个为0),默认为0 * 若需调整大小需要提供目标的width、height,默认为0,不需要 * time 画面停顿时间,以10ms为单位,默认为0 * action 处置方式:0 不处置;1 不能处置;2 恢复背景色;3 恢复成前一图形,默认为0 * $width 数值,目标图片宽 * $height 数值,目标图片高 * $imagename 字符串,目标文件名,缺省直接输出到浏览器 **/ function parse($image, $width, $height, $imagename='') { if(! is_array($image)) trigger_error('参数不足,无法生成动画', E_USER_ERROR); $width > 0 && $height > 0 or trigger_error('目标图片尺寸错', E_USER_ERROR); foreach($image as $img) { foreach($this->args_dict as $key) { if(! isset($img[$key])) $img[$key] = 0; } if(! is_file($img['filename'])) { trigger_error("文件 $img[filename] 不存在", E_USER_WARNING); continue; } $img['resources'] = new TGif($img['filename']); $this->source[] = $img; } $this->image_header($width, $height); $this->application_extension(); foreach($this->source as $i=>$img) { extract($img); $this->control_extension($resources, $frame, $time, $action); $this->image_frame($resources, $frame, $left, $top, $width, $height); } $this->image_end($imagename); }}?>这是部分大码 , 原理大概是在img图像上铺一个层? 请看帖:http://ken.bokele.com/?ArticleID=15492 php無限分類產品應該大約是怎樣做? 如何屏蔽 表单提交过来的数据? 有关网址的正则表达式看不懂? 帮忙看下sql语句 大家推荐本PHP的教程吧! if条件判断后面的:冒号什么意思 php下 如何生成动态页? 刚安装好apache就启动不了,帮手看看log,教教我啦,大虾们!也教教我怎么看 在zend编译器中为什么没有__set,__get等魔法函数,要怎么设置才能有 请教下面句子的含义 php 调出数据库大量数据过慢的问题 新的一年更上一层楼!
这是我自己搞的结果,大家帮忙看下吧 !!!
$k = 15;
$ar = array(
array(
'filename' =>'frames/frame0.gif',
'top' => 0,
'left' => 0,
'action' => 1,
'time' => $k,
),
array(
'filename' =>'frames/frame1.gif',
'top' => 0,
'left' => 0,
'action' => 2,
'time' => $k,
),
);
$gif = new TGifAnimation;
//合并多张gif图片为一张gif图片
$gif->parse($ar, $width, $height);
<?php
include_once 'imac_ReadGif.php';
class TGifAnimation {
var $args_dict = array(
'filename',
'left',
'top',
'width',
'height',
'frame',
'action',
'time',
);
var $source = array(); /**
* 输出应用程序扩展段
**/
function application_extension() {
printf("%c%c%cNETSCAPE2.0%c%c%c%c%c",0x21,0xff,11,3,1,0,0,0);
} /**
* 输出图象扩展控制段
**/
function control_extension(&$resources, $frame, $delay_time=10, $disposal_mothod=0) {
$resources->control_extension($frame, $delay_time, $disposal_mothod);
} /**
* 输出一帧图象
**/
function image_frame(&$resources, $frame, $left, $top, $width, $height) {
if($top >= 0 && $left >= 0 && ($width ==0 || $height == 0))
return $resources->image_frame($frame, $left, $top, $this->global_color_table); //当图象位置越出图片范围或需要调整图象大小时,执行以下代码
$width or $width = $resources->image[$frame]['width'];
$height or $height = $resources->image[$frame]['height']; //取得原图透明色索引
$transparecy_index = $resources->image[$frame]['transparecy_index']; //导出原图图象
$buf = $resources->withdraw($frame);
$sim = imagecreatefromstring($buf);
$dim = imagecreate($width, $height); //复制原图调色板到目标图
imagepalettecopy($dim, $sim);
imagefill($dim , 0, 0, $transparecy_index);
imagecolortransparent($dim, $transparecy_index); //调整截取位置并复制原图到目标图
$x = $y = 0;
if($left < 0) list($left, $x) = array($x, $left);
if($top < 0) list($top, $y) = array($y, $top);
imagecopyresized($dim, $sim, $x, $y, 0, 0, $width, $height, imagesx($sim), imagesy($sim)); //生成目标图片数据
ob_start();
imagegif($dim);
ImageDestroy($sim);
ImageDestroy($dim);
$buf = ob_get_clean(); //从目标图片数据中提取图象
$t = new TGif($buf);
$t->image_frame(0, $left, $top, $this->global_color_table);
} /**
* 输出图片头
**/
function image_header($width, $height) {
ob_start();
$this->global_color_table = $this->source[0]['resources']->global_color_table;
$flag = $this->source[0]['resources']->flag;
printf("GIF89a%s%s%c%c%c", pack("S", $width), pack("S", $height), $flag, 0, 0);
echo $this->global_color_table;
} /**
* 输出图片尾,并选择输出方向
**/
function image_end($filename) {
echo chr(0x3b);
$buf = ob_get_clean();
if(empty($filename)) {
header("Content-type: image/gif");
echo $buf;
//Imagegif($buf);
//ImageDestroy($buf);
}else
file_put_contents($filename, $buf);
} /**
* 合成动画
* 参数
* $image 数组,必须有filename元素
* left 图象在图片中的左边距,默认为0
* top 图象在图片中的上边距,默认为0
* frame 若filename有多帧需要指明帧号(第一个为0),默认为0
* 若需调整大小需要提供目标的width、height,默认为0,不需要
* time 画面停顿时间,以10ms为单位,默认为0
* action 处置方式:0 不处置;1 不能处置;2 恢复背景色;3 恢复成前一图形,默认为0
* $width 数值,目标图片宽
* $height 数值,目标图片高
* $imagename 字符串,目标文件名,缺省直接输出到浏览器
**/
function parse($image, $width, $height, $imagename='') { if(! is_array($image)) trigger_error('参数不足,无法生成动画', E_USER_ERROR);
$width > 0 && $height > 0 or trigger_error('目标图片尺寸错', E_USER_ERROR);
foreach($image as $img) {
foreach($this->args_dict as $key) {
if(! isset($img[$key]))
$img[$key] = 0;
}
if(! is_file($img['filename'])) {
trigger_error("文件 $img[filename] 不存在", E_USER_WARNING);
continue;
}
$img['resources'] = new TGif($img['filename']);
$this->source[] = $img;
}
$this->image_header($width, $height);
$this->application_extension(); foreach($this->source as $i=>$img) {
extract($img);
$this->control_extension($resources, $frame, $time, $action);
$this->image_frame($resources, $frame, $left, $top, $width, $height);
}
$this->image_end($imagename);
}
}
?>这是部分大码 ,