Hello,

This mod automatically watermark all uploaded photos.

Price: FREE, enjoy.

You will have to edit 3 files:

1. ../classes/image.class.php - watermark function.
2. ../modules/upload/photo.php - when upload photos from upload page.
3. ../modules/album/addphotos.php - when add photos to existing album.
---------------------------------------------

1. In "../classes/images.class.php" find (~ line 195):

public function watermark()
{
}

and replace with:

	public function watermark($SourceFile, $WatermarkFile, $SaveToFile = NULL)
{
$watermark = @imagecreatefrompng($WatermarkFile)
or exit('Cannot open the watermark file.');
imageAlphaBlending($watermark, false);
imageSaveAlpha($watermark, true);
$image_string = @file_get_contents($SourceFile)
or exit('Cannot open image file.');
$image = @imagecreatefromstring($image_string)
or exit('Not a valid image format.');
$imageWidth=imageSX($image);
$imageHeight=imageSY($image);
$watermarkWidth=imageSX($watermark);
$watermarkHeight=imageSY($watermark);
$coordinate_X = ( $imageWidth - 5) - ( $watermarkWidth);
$coordinate_Y = ( $imageHeight - 5) - ( $watermarkHeight);
imagecopy($image, $watermark, $coordinate_X, $coordinate_Y, 0, 0, $watermarkWidth, $watermarkHeight);
if(!($SaveToFile)) header('Content-Type: image/jpeg');
imagejpeg ($image, $SaveToFile);
imagedestroy($image);
imagedestroy($watermark);
if(!($SaveToFile)) exit;
}

2. In "../modules/upload/photo.php" find (~ line 90):

    $dst        = $config['BASE_DIR']. '/media/photos/' .$photo_id. '.jpg';
$image->process($src, $dst, 'MAX_WIDTH', 575, 0);
$image->resize(true, true);

and after "$image->resize(true, true);" insert this:

	$image_location = $config['BASE_DIR']. '/media/photos/' .$photo_id. '.jpg'; 
// Locate the watermark file wherever you choose (remember PNG format). I put in ../media/photos/watermark.png
$watermark_location = $config['BASE_DIR']. '/media/photos/watermark.png';
$save_watermarked_file_to = $config['BASE_DIR']. '/media/photos/' .$photo_id. '.jpg';
$image->watermark($image_location, $watermark_location, $save_watermarked_file_to);

3. In "../modules/album/addphotos.php" find (~ line 40):

    $dst            = $config['BASE_DIR']. '/media/photos/' .$photo_id. '.jpg';
$image->process($src, $dst, 'MAX_WIDTH', 575, 0);
$image->resize(true, true);

and like the previous after "$image->resize(true, true);" insert this:

	$image_location = $config['BASE_DIR']. '/media/photos/' .$photo_id. '.jpg'; 
// Locate the watermark file wherever you choose (remember PNG format). I put in ../media/photos/watermark.png
$watermark_location = $config['BASE_DIR']. '/media/photos/watermark.png';
$save_watermarked_file_to = $config['BASE_DIR']. '/media/photos/' .$photo_id. '.jpg';
$image->watermark($image_location, $watermark_location, $save_watermarked_file_to);

!!! ++$photos; must be below the pasted code.

There is screens from thats files after mods.

image.class.php

1. ../classes/image.class.php - watermark function.
i did a copy

2. ../modules/upload/photo.php - when upload photos from upload page.

    $image->process($src, $dst, 'MAX_WIDTH', 575, 0);
$image->resize(true, true);
$dst = $config['BASE_DIR']. '/media/photos/' .$photo_id. '.jpg';
$image->process($src, $dst, 'MAX_WIDTH', 575, 0);
$image->resize(true, true);
$image_location = $config['BASE_DIR']. '/media/photos/' .$photo_id. '.jpg';
// Locate the watermark file wherever you choose (remember PNG format). I put in ../media/photos/watermark.png
$watermark_location = $config['BASE_DIR']. '/media/photos/watermark.png';
$save_watermarked_file_to = $config['BASE_DIR']. '/media/photos/' .$photo_id. '.jpg';
$image->watermark($image_location, $watermark_location, $save_watermarked_file_to);

3. ../modules/album/addphotos.php - when add photos to existing album.

                $image->process($src, $dst, 'MAX_WIDTH', 575, 0);
$image->resize(true, true);
$dst = $config['BASE_DIR']. '/media/photos/' .$photo_id. '.jpg';
$image->process($src, $dst, 'MAX_WIDTH', 575, 0);
$image->resize(true, true);
$image_location = $config['BASE_DIR']. '/media/photos/' .$photo_id. '.jpg';
// Locate the watermark file wherever you choose (remember PNG format). I put in ../media/photos/watermark.png
$watermark_location = $config['BASE_DIR']. '/media/photos/watermark.png';
$save_watermarked_file_to = $config['BASE_DIR']. '/media/photos/' .$photo_id. '.jpg';
$image->watermark($image_location, $watermark_location, $save_watermarked_file_to); ++$photos; think somewhere there is error
                $image->process($src, $dst, 'MAX_WIDTH', 575, 0);
$image->resize(true, true);
$dst = $config['BASE_DIR']. '/media/photos/' .$photo_id. '.jpg';
$image->process($src, $dst, 'MAX_WIDTH', 575, 0);
$image->resize(true, true);

in my code not 2x "'MAX_WIDTH', 575, 0"

its looks like you added that to:
    $dst        = $config['BASE_DIR']. '/media/photos/' .$photo_id. '.jpg';
$image->process($src, $dst, 'MAX_WIDTH', 575, 0);
$image->resize(true, true);

but I was thinking to be pasted after that  

Automatically watermark all uploaded photos (给所有上传的相片加水印)的更多相关文章

  1. thinkphp 3.2.3整合ueditor 1.4,给上传的图片加水印

    今天分享一下thinkphp 3.2.3整合ueditor 1.4,给上传的图片加水印.博主是新手,在这里卡住了很久(>_<) thinkphp 3.2.3整合ueditor 1.4 下载 ...

  2. PHP多图片上传 并检查 加水印 源码

    参数说明:$max_file_size : 上传文件大小限制, 单位BYTE$destination_folder : 上传文件路径$watermark : 是否附加水印(1为加水印,其他为不加水印) ...

  3. 百度编辑器ueditor给上传的图片加入水印

    百度编辑器本身是没有为上传图片加入水印的功能,想要在上传的时候加入图片水印,也非常easy.以 ueditor 1.2.6 为例.打开php文件夹以下的imageUp.php文件,查找"$i ...

  4. springMVC3.0(文件上传,@RequestMapping加參数,@SessionAttributes,@ModelAttribute,转发,重定向,数值获取,传參,ajax,拦截器)

    1.项目包结构例如以下: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdG90b3R1enVvcXVhbg==/font/5a6L5L2T/fontsiz ...

  5. Webform 文件上传、 C#加图片水印 、 图片验证码

    文件上传:要使用控件 - FileUpload 1.如何判断是否选中文件? FileUpload.FileName - 选中文件的文件名,如果长度不大于0,那么说明没选中任何文件 js - f.val ...

  6. PHP之图片上传类(加了缩略图)

    有缩略图功能 但是 感觉不全面,而且有点问题,继续学习,将来以后修改下 <form action="<?php $_SERVER['PHP_SELF']; ?>" ...

  7. 关于ueditor1_4_3 上传出现无法加载配置的问题

    我的解决方案是: 1. 检查 ueditor.config.js  中的 serverUrl: URL + "/net/controller.ashx" 的配置,记得一定用绝对路径 ...

  8. 解决Uploadify上传控件加载导致的GET 404 Not Found问题

    今天在项目发用到Uploadify上传, 发现在打开页面时会有一多余的请求,由于路由没有设置这个,导致404错误,能搜索查到以下解决的方法 <Uploadify v3 bug. Unecessa ...

  9. 初级版python登录验证,上传下载文件加MD5文件校验

    服务器端程序 import socket import json import struct import hashlib import os def md5_code(usr, pwd): ret ...

随机推荐

  1. SQL条件表达式

    需求:数据表中如果满足某个条件,返回表中所有数据,否则不返回数据. 语法:CASE 表达式是一种通用的条件表达式,类似于其它语言中的 if/else 语句. CASE WHEN condition T ...

  2. java一切乱码的解释 以及源头【转】

    工作中经常遇到java编码问题,由于缺乏研究,总是无法给出确切的答案,这个周末在网上查了一些资料,在此做些汇总. 问题一:在java中读取文件时应该采用什么编码? Java读取文件的方式总体可以分为两 ...

  3. dos 命令

    DOS远程桌面连接命令 mstsc /v: 192.168.1.250 /console cmd 运行 command删除文件 rd 文件名/S创建文件 MD 文件名 1. net user admi ...

  4. Python中 os._exit() sys.exit() exit()区别

    Python退出程序的方式有两种:os._exit(), sys.exit() 1)os._exit() 直接退出 Python程序,其后的代码也不会继续执行. 2)sys.exit() 引发一个 S ...

  5. c#简单数组

    int[,] a=new int[,]{{1,2},{3,4},{5,6}};//二维数组 textbox.text=a[0,1];//=2 int[][] b={new int[]{1,2},new ...

  6. Java 日志缓存机制的实现--转载

    概述 日志技术为产品的质量和服务提供了重要的支撑.JDK 在 1.4 版本以后加入了日志机制,为 Java 开发人员提供了便利.但这种日志机制是基于静态日志级别的,也就是在程序运行前就需设定下来要打印 ...

  7. 从实践谈iOS生命周期

    从实践谈iOS生命周期 个人感觉生命周期无论在Android,还是iOS都是很重要的概念,因为在每个声明周期的状态下我们可以做很多预加载或者处理的操作.因此在这里主要总结下ViewController ...

  8. .net框架介绍

    .net 一般指 .net Framework框架,是一种平台,一种技术 C# 是一种编程语言,可以开发基于.net平台的应用 Java 既是一种技术,也是一种语言 .net可以开发桌面应用程序    ...

  9. jquery.placeholder.js的使用

    最近做东西用到placeholder这个属性,可是这个属性在低版本的IE或者QQ浏览器等这些浏览器上这个属性不能生效,后来在网上查了下,发现了jquery的一个插件jquery.placeholder ...

  10. 电脑安装win8.1后 前面板没有声音的解决办法

    解决部分朋友在给电脑新安装win8.1系统后出现耳机插入电脑前面板音频口没有声音的问题 百度经验:jingyan.baidu.com 方法/步骤 1 1.安装声卡驱动(必须安装,否则无法完成设置) 2 ...