Skip to content

【原创】wordpress图片水印+远程图片下载插件super image tools

转载本站文章请注明:
转载来至:[记录与PHP的PK经历]
本文链接: 【原创】wordpress图片水印+远程图片下载插件super image tools

【介绍】
1.本插件能够实现wordpress上传图片自动增加水印
2.可以添加图片水印和文字水印两种类型
3.可以对已经存在的图片进行批处理添加水印
4.可以对文章内容中的外部引用图片自动下载并添加水印
5.对自动下载的图片添加为wp附件,方便管理

【简单安装】
注解:本安装只能实现博客内容中包括的图片添加水印,即只有博客内容中的<img src=”">标签引用的图片才会被添加水印,如果你上传了图片但是博客中使用了缩略图,那么只有缩略图添加水印!
1. 下载zip文件,解压后把imagesupertools文件夹放入wp-content/plugins目录,然后在Plugins页面激活该插件。
2. 在setting->ImageSuperTools->ContentImageDown菜单下的两个设置均设置为Yes。

【高级安装】
注解:按照本方法安装能够实现上传图片源文件和缩略图均添加水印。
首先按照【简单安装】第一步操作完毕然后进行如下操作:

1. 打开/wordpress/wp-admin/includes/media.php查找(大约第108行)
// Save the data
$id = wp_insert_attachment($attachment, $file, $post_parent);

在这段代码上面添加如下代码:
// INSERT HERE!!!
if (function_exists("IM_mark"))
{
IM_mark($file,$op="overwrite");
}



2. 如果你要在你上传的图片缩略图和中型图片添加水印请进行如下操作,要求版本Wordpress v2.5.1:
打开/wordpress/wp-includes/media.php查找如下代码(大约第230行)
imagedestroy( $newimage );
在这段代码上面添加如下代码
// INSERT HERE!!!
if (function_exists("IM_mark"))
{
IM_mark($destfilename,$op="overwrite");
}


【注意】
1.安装完毕后替换mark.png为你自己的水印图片
2.fonts目录中的字体你可以自己替换,使用windows的ttf字体都可以
3.如果你使用文字水印而且使用中文,请选择字体chinese.ttf ,否会出现乱码

【详细功能介绍】

1.本插件可以手动对已存在的图片添加水印操作
2.本插件具有图片备份功能,即在图片添加前对图片进行备份,可以随时恢复到没有添加水印前的状态
3.添加了具有在线管理图片的功能,能够批量删除已经存在的图片
4.文字水印和图片水印可以进行位置精确操作
5.可以根据图片大小设置判断是否给图片添加水印

新版下载:Super Image Plugin
插件主页:Super Image Plugin插件主页
本人博客:http://www.pkphp.com/

36 Comments

  1. imstu

    嗨,你好,每次启用,都会出现这样的错误:

    Warning: is_writable() [function.is-writable]: open_basedir restriction in effect. File(/var/log/php_err.log) is not within the allowed path(s): (/www/winetcn/tmp/:/tmp/:/www/winetcn/murekecom/:/usr/local/php5/lib/php/) in /www/winetcn/murekecom/wp-includes/wp-db.php on line 199

    Warning: is_writable() [function.is-writable]: open_basedir restriction in effect. File(/var/log/php_err.log) is not within the allowed path(s): (/www/winetcn/tmp/:/tmp/:/www/winetcn/murekecom/:/usr/local/php5/lib/php/) in /www/winetcn/murekecom/wp-includes/wp-db.php on line 199

    Warning: Cannot modify header information - headers already sent by (output started at /www/winetcn/murekecom/wp-includes/wp-db.php:199) in /www/winetcn/murekecom/wp-includes/pluggable.php on line 694、

    是怎么导致的呢,希望以后完善并更好,谢谢你的努力!

    Posted on 06-Jul-08 at 9:23 am | Permalink
  2. askie

    这个好像是你文件权限的问题,与插件没有关系!

    Posted on 06-Jul-08 at 2:14 pm | Permalink
  3. 2个BUG!
    1.WP自身上传的图片image super tools也会当远程图片下载下来…
    2.image super tools远程下载图片,不是下载一张..而是多张…即,一张图片,下载多次..命名为XX01..XX02..XX03…XX04等等..有的多达20+张…最少也有两三张…

    Posted on 13-Jul-08 at 7:02 am | Permalink
  4. askie

    我测试过了,本地的图片是不会重复下载,是否是本地图片是根据图片URL判断的,如果图片Url以博客Url开头那么就判断为本地图片,忽略下载!

    Posted on 13-Jul-08 at 10:06 am | Permalink
  5. 难道和其他插件用冲突?
    我将服务器的图片下载下来..才发现的…相同的图片N多~

    Posted on 13-Jul-08 at 4:27 pm | Permalink
  6. 是了.我是选择简单安装的….你测试的是高级安装吗?

    Posted on 13-Jul-08 at 4:28 pm | Permalink
  7. 下载本地图片的原因估计是我直接在wp-config.php添加固定网址参数,而没有修改数据库的网址….之前换个域名测试

    第2个问题.我想你早也料到.如果服务器有相同文件名的.就自动在文件名后面添加01.等命名方式…
    能不能修改为,有相同文件名的就不下载.只改链接?

    Posted on 13-Jul-08 at 5:14 pm | Permalink
  8. 最新测试…新装WP2.5.1版…可以下载远程图片..但连续下载2次,即2张相同的…
    虽然成功下载远程图片..当文章的图片URL没有修改…..
    测试网址http://armory.maoxmao.com/
    密码123456

    Posted on 13-Jul-08 at 5:48 pm | Permalink
  9. askie

    修正了这个bug!
    这个bug是因为在编辑时候自动存储引起的!
    请更新最新版本吧!
    谢谢你的反馈!

    Posted on 16-Jul-08 at 1:56 am | Permalink
  10. raidsan

    wp2.6, 用了以后发现有的图片没有加上水印, 检查 wp-admin\includes\media.php 看到里面连续有两个方法:
    function media_handle_upload
    function media_handle_sideload

    里面都有
    // Save the data
    $id = wp_insert_attachment($attachment, $file, $post_parent);
    是两个地方都要加吗?

    另外:在setting 插件里面 搜索 图片加水印的功能, 默认搜索路径能否改为 content的update路径? 现在是插件安装路径,不合适啊。 还有,搜索到图片后加水印时,是否检查了 水印记录文件,如果存在就不再添加, 这样似乎不妥。最好是提示一下用户,如果用户自己确认没有加过,那就重新再加一次,水印信息文件重新生成就是。

    Posted on 04-Aug-08 at 6:34 pm | Permalink
  11. raidsan

    实在不行的话,我只好在本地加了水印了,这样保持图片版本一致最好。

    Posted on 04-Aug-08 at 6:36 pm | Permalink
  12. raidsan

    我找到问题原因了,我用WP的媒体库管理功能删除了一些图片,然后重新上传,而文件名是一样的。这样以前生成的.bak文件还在。 所以插件得再改一下,在创建备份文件时需要覆盖已有的文件。目前好像是无法覆盖,结果新的加了水印的.gif 没有正确生成, 内容格式未知。

    Posted on 04-Aug-08 at 7:20 pm | Permalink
  13. askie

    那我将来增加一个选项吧!谢谢你的建议!

    Posted on 04-Aug-08 at 7:27 pm | Permalink
  14. raidsan

    怪了,源码里面有 @unlink .bak文件啊。那为什么我wp目录下的图片文件状态,.bak文件是以前版本的图片呢? 新的文件上传后加水印过程中没有覆盖掉旧的.bak文件……

    Posted on 04-Aug-08 at 7:28 pm | Permalink
  15. 很好 很强大

    Posted on 26-Aug-08 at 11:08 pm | Permalink
  16. 你好!我在使用的时候,水印的预览发生的错误,打开预览图是以下错误代码:Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /usr/local/psa/home/vhosts/ebuyed.com/httpdocs/wp-content/plugins/super-image-plugin/ImageShuiYin.php on line 24

    谢谢!期待你的邮件。

    Posted on 07-Sep-08 at 10:06 pm | Permalink
  17. askie

    @Usuning 这个问题是因为代码没有兼容php4和5引起的,现在已经修正了。你重新下载覆盖插件即可!

    Posted on 07-Sep-08 at 11:02 pm | Permalink
  18. Usuning

    修正的版本在哪里下载?给个地址。

    Posted on 08-Sep-08 at 1:46 pm | Permalink
  19. askie

    就在wp官方,原来的下载地址

    Posted on 08-Sep-08 at 2:23 pm | Permalink
  20. 不是吧!我下载了,我看文件日期不对呀。Last Updated: 2008-8-31
    还是这个日期的。
    不过还是下载了,上传去也不行呀。。看不到东西呀。。

    谢谢!能否解决一下。。

    Posted on 08-Sep-08 at 8:05 pm | Permalink
  21. jing

    修改已发布文章,文章中的外部图片并未下载?

    Posted on 09-Sep-08 at 1:48 am | Permalink
  22. askie

    有些网也代码不规范可能会引起程序无法获取图片的情况,大部分情况下都是没问题的,你再测试看看

    Posted on 09-Sep-08 at 11:21 am | Permalink
  23. dkdk

    安装了最新的1.9, 可Preview处一直无法预览,只有叉叉, 水印也一直添加不了。 自制的水印mark.png文件是可以显示的。 急盼解决办法! wordpress是2.6.2

    Posted on 20-Sep-08 at 8:46 am | Permalink
  24. askie

    是不是你的空间没有开放GD库?

    Posted on 20-Sep-08 at 8:55 am | Permalink
  25. 刚在WP下载的此插件安装不成功,添加文章时提示:Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in www/wp-content/plugins/super-image-plugin/ImageShuiYin.php on line 24

    请问这是什么问题,谢谢

    Posted on 23-Sep-08 at 3:03 am | Permalink
  26. askie

    请下载最新版本,这个可能是你的php版本太小引起的

    Posted on 23-Sep-08 at 7:53 am | Permalink
  27. wj

    粘贴过来的图片地址/链接地址会自动替换成http://www.xxx.com/wp-admin/图片文件名或者文件名,这是为什么?WP2.6.1

    Posted on 23-Sep-08 at 5:00 pm | Permalink
  28. askie

    没明白你的意思!

    Posted on 23-Sep-08 at 9:54 pm | Permalink
  29. 已经是wordpress.org上的最新版本,另我的PHP版本是5.0的

    Posted on 24-Sep-08 at 1:54 pm | Permalink
  30. askie

    我检查了代码,没有什么问题!很奇怪啊!

    Posted on 24-Sep-08 at 6:59 pm | Permalink
  31. 请问我一直报错
    Warning: filemtime() [function.filemtime]: stat failed for /home/content/d/e/l/delychi/html/wp-content/uploads/2008/10/4a39_WMF_Logo.jpg in /home/content/d/e/l/delychi/html/wp-content/plugins/super-image-plugin/imagesupertools.php on line 732

    Warning: Cannot modify header information - headers already sent by (output started at /home/content/d/e/l/delychi/html/wp-content/plugins/super-image-plugin/imagesupertools.php:732) in /home/content/d/e/l/delychi/html/wp-includes/pluggable.php on line 770

    请问这个应该修改哪里的目录文件权限?
    upload目录我以前设置成777权限了

    Posted on 01-Oct-08 at 8:22 pm | Permalink
  32. askie

    @brand2home 应该4a39_WMF_Logo.jpg文件个格式不正确引起的错误!不是权限问题!

    Posted on 02-Oct-08 at 12:02 pm | Permalink
  33. 谢谢。发现问题了
    原来是采用中文SEO插件。自动把标签的单词转化成连接
    结果这个图片包含标签单词被插入了
    取消这个功能后恢复正常。现在使用效果很好。谢谢

    Posted on 03-Oct-08 at 5:17 pm | Permalink
  34. aaron

    简单安装,wordpress2.7,会出现下面问题,不知道怎么回事:
    Warning: file_get_contents() [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/w810209/public_html/desktop/wp-content/plugins/super-image-plugin/imagesupertools.php on line 868

    Posted on 06-Jan-09 at 1:44 pm | Permalink
  35. askie

    已经修复!请下载最新版本!

    Posted on 06-Jan-09 at 7:10 pm | Permalink
  36. aaron

    博主真是有效率,问题解决了,谢谢啊。
    不过还有个问题,说是可以对已经存在的图片进行批处理添加水印,但是试了半天,也不知道这个功能在哪里啊。

    还有,2.7的那句$id = wp_insert_attachment($attachment, $file, $post_parent);
    变成了:
    $id = wp_insert_attachment($attachment, $file, $post_id);

    而且里面有两句一样的,不知道代码加在哪个上面呢

    Posted on 07-Jan-09 at 3:11 am | Permalink

4 Trackbacks/Pingbacks

  1. Image super tools on 11-Jun-08 at 11:07 pm

    [...] 更详细的是用请看 Askie 的文章:wordpress图片水印+远程图片下载插件image super tools [...]

  2. [...] 虽然WordPress已经有自动给图片加水印的插件了(呦呦~~~就是这个super image tools), 而且这个东西牛X到不行,连远程图片也可以轻松搞定; 但就是不符合我的口味,Why?大哥辛苦了,小弟很勤奋,每张图片我都要亲自照顾一下。 以前写过一个简单的Python图片处理程序,现在权当复习一下。 [...]

  3. [...] 新版下载:Super Image Plugin 插件介绍:Super Image Plugin插件介绍 插件主页:Super Image Plugin插件主页 本人博客:http://www.pkphp.com/ 相关文章: [...]

  4. [...] 更详细的是用请看 Askie 的文章:wordpress图片水印+远程图片下载插件image super tools [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*