import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.color.ColorSpace;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.awt.image.ColorConvertOp;
import java.awt.image.CropImageFilter;
import java.awt.image.FilteredImageSource;
import java.awt.image.ImageFilter;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Connection;
import java.sql.ResultSet;
import javax.imageio.ImageIO;
import javax.naming.NamingException;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.justep.baas.action.ActionContext;
import com.justep.baas.data.sql.SQLException;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
/**
* 图片处理工具类:<br>
* 功能:缩放图像、切割图像、图像类型转换、彩色转黑白、文字水印、图片水印等
* @author Administrator
*/
public class ImageUtls {
/**
* 几种常见的图片格式
*/
public static String IMAGE_TYPE_GIF = "gif";// 图形交换格式
public static String IMAGE_TYPE_JPG = "jpg";// 联合照片专家组
public static String IMAGE_TYPE_JPEG = "jpeg";// 联合照片专家组
public static String IMAGE_TYPE_BMP = "bmp";// 英文Bitmap(位图)的简写,它是Windows操作系统中的标准图像文件格式
public static String IMAGE_TYPE_PNG = "png";// 可移植网络图形
public static String IMAGE_TYPE_PSD = "psd";// Photoshop的专用格式Photoshop
private static BASE64Encoder base64en = new BASE64Encoder();
private static BASE64Decoder base64de = new BASE64Decoder();
//水印图片base64码
private static String shuiyingImg = "iVBORw0KGgoAAAANSUhEUgAAAMgAAABNCAIAAABsR7yiAAA66klEQVR42u29d5hlR3kn/L5VdcLNfW/nHCb3ZGlmlEGYILItwCYsBrM89hr741uHXbP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rFkbHmed310bHj4+uJiGoAYY83Njfv29gfZP7dQ9bIFVm1qc7nczOycU3EaGxtSK3LHtspcEylNBl82gdOZzNjY+OTkTDqdISLTMhsaUjt3bO/q7MAVJtet8rKVWCvhlc8XJiensvm8wXl9Q0NdXSK5RobRjXTrDeKtXMnlcguLmampqUwm6zgOIMai0daW5t7e7paW5puG0G+VlxWwVrkGwZ6+qemZTCYbsm0iCkfCqWQyGo2Ypsk5Q8YCslEpVSqVstlcoVB0HGcxnS4UikH2SDQaTSbrOjraGhsbE/HY/y3P61b5vwysdR0ZpXQ6nc5kcwsLC4VC0fM835dBCUJRSimiIJVRWJYZDocj4XAqlWxoqI/H4wHjt3WH9lZ52QLrptxGuVwpFosVx9FKEwFjgMgMQ4TCoVgsKrjYOlVzq/xbBNZGVMr36JZb5V9/+T8beJizE3DiLwAAAABJRU5ErkJggg==";
/**
* 根据base64码加上水印后返回新的base64码
* @param srcStr 照片base64字符串
* @return
*/
//******************************************main主方法
public static JSONObject UdateLocalStandClassDatajava1(JSONObject params, ActionContext context) throws SQLException, NamingException, java.sql.SQLException {
//站班汇报同步数据代码 ,然后要执行加水印的步骤
Connection conn = (Connection) context.getConnection("jeecg37bzb");// 获取数据库连接
java.sql.Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
// 参数集合
String url ="D:/Wex5/Wex5_180117/model/UI2/BZB01/project/project_img";
java.sql.Date currentDate = new java.sql.Date(System.currentTimeMillis());//获取sql java呼唤时间
//参数列表
JSONObject result = new JSONObject();//返回结果集
String N_json = params.getString("json");//获取参数
JSONArray json2 = JSONArray.parseArray(N_json);//数据转换
String new_pic = "@@@";//临时承接图片水印路径集合
//遍历循环
for(int i =0;i<json2.size();i++){
JSONObject json3 =json2.getJSONObject(i);//先转换成数组后转成对象,因为只有对象才有取值属性
Object v_id = json3.get("k_id");
Object v_name = json3.get("k_name");
Object v_time = json3.get("k_time");
Object v_addre = json3.get("k_address");
String v_pic = (String) json3.get("fPictureUrl");
System.out.println("解析后的数据是:"+v_id+"#"+v_time+"#"+v_addre+"#"+v_pic);
//解析出来条数据, 切割图片路径
String[] pic = v_pic.split("@@@");//切割图片
//循环数组
for(int k= 0;k<pic.length;k++){
String pic_l=pic[k];//单个图片
String dt =pic_l.replace("data:image/jpeg;base64,","");//转换图片bas
if(!dt.equals("null")){//判断是否为空
//转换图片
System.out.println("替换成图片"+dt);
base64ToImage(dt,v_id+"old.png");//数据流转成图片
//拼接
ImageUtls.pressText("人员"+v_name,url+v_id+"old.png",
url+v_id+"new.png",
"宋体",Font.PLAIN,Color.white,10,80,110, 0.5f);//测试OK
ImageUtls.pressText("时间"+v_time,url+v_id+"new.png",
url+v_id+"new1.png",
"宋体",Font.PLAIN,Color.white,10,80,130, 0.5f);//测试OK
ImageUtls.pressText("地址"+v_addre,url+v_id+"new1.png",
url+v_id+"new2.png",
"宋体",Font.PLAIN,Color.white,10,80,150, 0.5f);//测试OK
//最后把水印图片转码回来
String newStr = "data:image/jpeg;base64,"+imageToBase64(url+v_id+"new2.png");
System.out.println("加 水印之后新的base64 字节码base是:"+newStr);
//
new_pic+=newStr+"@@@";
}
}
//图片拼接完成,根据id更新数据
String updatezbpicturl2 ="update pm_project_statreport m set m.fPictureUrl='"+new_pic+"' where m.fID ='"+v_id+"'";//更新图片路径
stmt.executeUpdate(updatezbpicturl2);
System.out.println("插入成功");
conn.close();
}
//
//
//
JSONObject result = new JSONObject();//返回结果集
//
JSONArray sData = new JSONArray();//封装data
//
//
JSONArray userCode = (JSONArray) params.get("json");//获取参数 数组arr
//
System.out.println("站班汇报获取到的数据值是:"+userCode);
//
String st_st="已提交";
//
String img_xgh1="修改后";
//
String url ="C:/Work/WeX536BZB/model/UI2/ProjectSubcontracting/ProjectSub_Classmeeting/img";
//
Object[] o = userCode.toArray();
//
遍历循环的数据
//
for(int i= 0;i<o.length;i++){
//
System.out.println("数组中的数据是:" + o[i].toString());
//
//切割
//
String rows = o[i].toString();//接收rows转换成string
//
String[] rowscut = rows.split("#");//切割后的分别取到参数
//
String Sj_fID =rowscut[0];//主键
//
String Sj_fProjectName=rowscut[1];//项目
//
String Sj_fPlaceName=rowscut[2];//地点
//
String Sj_fReachSum =rowscut[3];//应到
//
String Sj_fReachbackSum=rowscut[4];//实到
//
String Sj_fPictureUrl=rowscut[5];//预览地址图片
//
String Sj_fPicturePiao=rowscut[6];//地理位置
//
String Sj_fNo=rowscut[7];//班组人员id
//
String Sj_fTextType=rowscut[8];//文件状态
//
String Sj_fProjectID=rowscut[9];//项目ID
//
String Sj_personName=rowscut[10];//人员名称
//
String Sj_personid=rowscut[11];//人员ID
String Sj_newtime=rowscut[12];//人员ID
var fProjectID = localStorage.getItem("NowfProjectID");//获取缓存中的项目ID
var personName = localStorage.getItem("personName");
var personid = localStorage.getItem("personID");
var personid = localStorage.getItem("personID");
var fProjectID = localStorage.getItem("NowfProjectID");
//
//拆分图片路径转传承水印路径
//
String new_Sj_fPicts = "@@@";//临时承接图片水印路径集合
//
String[] fv_sURLsp = Sj_fPictureUrl.split("@@@");//获取单个url切割后的数组
//
for(int j= 0;j<fv_sURLsp.length;j++){
//
//
//
//
String Sj_fPictureUrl_sURL=fv_sURLsp[j];//获取单个的图片的base路径 GGGGGG
//
//
//
String dt =Sj_fPictureUrl_sURL.replace("data:image/jpeg;base64,","");
//
//
System.out.println("切割后的单个数据是之前:"+Sj_fPictureUrl_sURL);
//
System.out.println("替换后的数据是:"+dt);
//
//转换图片
//
if(!dt.equals("null")){
//
System.out.println("替后的数据是:"+dt);
//
base64ToImage(dt,url+Sj_fProjectName+Sj_fPlaceName+j+"old.png");//数据流转成图片
//
//拼接
//
ImageUtls.pressText("班组 "+Sj_personName,url+Sj_fProjectName+Sj_fPlaceName+j+"old.png",
//
url+Sj_fProjectName+Sj_fPlaceName+j+"new1.png",
//
"宋体",Font.PLAIN,Color.white,10,80,110, 0.5f);//测试OK
//
ImageUtls.pressText("时间"+currentDate,url+Sj_fProjectName+Sj_fPlaceName+j+"new1.png",
//
url+Sj_fProjectName+Sj_fPlaceName+j+"new2.png",
//
"宋体",Font.PLAIN,Color.white,10,80,130, 0.5f);//测试OK
//
ImageUtls.pressText("桩号"+Sj_fPlaceName,url+Sj_fProjectName+Sj_fPlaceName+j+"new2.png",
//
url+Sj_fProjectName+Sj_fPlaceName+j+"new3.png",
//
"宋体",Font.PLAIN,Color.white,10,80,150, 0.5f);//测试OK
//
//
//
String newStr = "data:image/jpeg;base64,"+imageToBase64(url+Sj_fProjectName+Sj_fPlaceName+j+"new3.png");
//
System.out.println("加 水印之后新的base64————++++的字节码base是:"+newStr);
//
//
//
new_Sj_fPicts+=newStr+"@@@";
//
}
//
}
//
//执行sql插入语句
//
System.out.println("遍历出来的数据是:"+Sj_fID+Sj_fPlaceName+Sj_fReachSum+Sj_fReachbackSum+Sj_fPictureUrl+Sj_fPicturePiao+Sj_fNo+Sj_fTextType);
//
//遍历插入表数据
//
String sql ="insert into pm_project_statreport (fID,fProjectName,fPlaceName,fReachSum,fReachbackSum,fPictureUrl,fPicturePiao,fNo,fTextType,fProjectID,fWriteName,fWrtiesID,fWrtieTime)" +"values"+"('"+Sj_fID+"','"+Sj_fProjectName+"','"+Sj_fPlaceName+"','"+Sj_fReachSum+"','"+Sj_fReachbackSum+"','"+new_Sj_fPicts+"','"+Sj_fPicturePiao+"','"+Sj_fNo+"','"+st_st+"','"+Sj_fProjectID+"','"+Sj_personName+"','"+Sj_personid+"','"+currentDate+"')";
//
//执行操作
//
stmt.executeUpdate(sql);
//
System.out.println("插入成功");
//
}
//
conn.close();
return result;
}
public final static String addWatermark(String srcStr) throws IOException,Exception{
//根据传递的base64图片的大小来决定水印图片的大小。
//处理透明信息
String newStr = "";
float alpha = 0.3F;
int srcWidth = 0;
int srcHeight = 0;
byte[] b ;
try {
b = base64de.decodeBuffer(srcStr);
InputStream is = new java.io.ByteArrayInputStream(b);
BufferedImage src = ImageIO.read(is);
if(src != null ){
srcWidth = src.getWidth(null);
srcHeight = src.getHeight(null);
if(srcWidth<=0||srcHeight<=0)
return null;
//根据原始图片变换水印图片的尺寸
BufferedImage waterMark = resize(shuiyingImg,srcWidth,srcHeight);
/*添加水印*/
BufferedImage img = new java.awt.image.BufferedImage(srcWidth, srcHeight,BufferedImage.TYPE_USHORT_565_RGB);
//创建画板
Graphics2D graph = img.createGraphics();
//把原图印到图板上
graph.drawImage(src,null,0,0);
//设置透明度,alpha
graph.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha));
//画水印图片
graph.drawImage(waterMark,null,0,0);
/*把图片转换为字节*/
ByteArrayOutputStream jpegOutputStream = new ByteArrayOutputStream();
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(jpegOutputStream);
encoder.encode(img);
byte[] resultByte = jpegOutputStream.toByteArray();
ImageIO.write(img, "jpg",new File("C:/Users/apple/Desktop/20170106213913407.jpg"));
System.out.println("加水印完成");
graph.dispose();
//System.out.println(base64en.encode(resultByte));
newStr = base64en.encode(resultByte);
}else{
System.out.println(11);
return null;
}
}catch (Exception e) {
e.printStackTrace();
}
return newStr;
}
/**
* 根据图片大小,自动变化水印图片大小。
* @param src:
* @param w:原图片宽度
* @param h:元图片高度
* @return:返回image
*/
public static BufferedImage resize(String src,int w,int h) {
byte[] b;
// 加载内存中的水印图片
try {
b = base64de.decodeBuffer(src);
InputStream is = new java.io.ByteArrayInputStream(b);
BufferedImage img = ImageIO.read(is);
// 获得适合的缩放比率,即以在规定缩略尺寸中完整显示图片内容的同时又保证最大的缩放比率
// 根据比例画出缓存图像
BufferedImage mini = new java.awt.image.BufferedImage(w, h,BufferedImage.TYPE_USHORT_565_RGB);
Graphics2D gmini = mini.createGraphics();
gmini.setBackground(Color.WHITE);
// 让生成的图片按相同的比例变换
gmini.clearRect(0, 0, w, h);
AffineTransform trans = new AffineTransform();
// 长和宽同时变换
trans.scale((double) w / img.getWidth(), (double) h/ img.getHeight());
gmini.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.7f));
AffineTransformOp op = new AffineTransformOp(trans,AffineTransformOp.TYPE_BILINEAR);
gmini.drawImage(img, op, 0, 0);
gmini.dispose();
return mini;
} catch (IOException e) {
return null;
}
}
/**
*
* @param args
public static void main(String[] args) {
String imgFile = "C:/Users/apple/Desktop/20170106213913407.png";//待处理的图片 不同图片类型加不同前缀
InputStream in = null;
byte[] data = null;
//读取图片字节数组
try{
in = new FileInputStream(imgFile);
data = new byte[in.available()];
in.read(data);
in.close();
}catch (IOException e){
e.printStackTrace();
}
//对字节数组Base64编码
BASE64Encoder encoder = new BASE64Encoder();
try {
String str = ImageUtls.addWatermark(encoder.encode(data));
System.out.print(str);
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
*/
/**
* 程序入口:用于测试
* @param args
*/
/* public static void main(String[] args) {
// 1-缩放图像:
// 方法一:按比例缩放
ImageUtls.scale("e:/abc.jpg", "e:/abc_scale.jpg", 2, true);//测试OK
// 方法二:按高度和宽度缩放
ImageUtls.scale2("e:/abc.jpg", "e:/abc_scale2.jpg", 500, 300, true);//测试OK
// 2-切割图像:
// 方法一:按指定起点坐标和宽高切割
ImageUtls.cut("e:/abc.jpg", "e:/abc_cut.jpg", 0, 0, 400, 400 );//测试OK
// 方法二:指定切片的行数和列数
ImageUtls.cut2("e:/abc.jpg", "e:/", 2, 2 );//测试OK
// 方法三:指定切片的宽度和高度
ImageUtls.cut3("e:/abc.jpg", "e:/", 300, 300 );//测试OK
// 3-图像类型转换:
ImageUtls.convert("e:/abc.jpg", "GIF", "e:/abc_convert.gif");//测试OK
// 4-彩色转黑白:
ImageUtls.gray("e:/abc.jpg", "e:/abc_gray.jpg");//测试OK
// 6-给图片添加图片水印:
ImageUtls.pressImage("e:/abc2.jpg", "e:/abc.jpg","e:/abc_pressImage.jpg", 0, 0, 0.5f);//测试OK
// 5-给图片添加文字水印:
base64ToImage(shuiyingImg, "C:/Users/apple/Desktop/liupeng.png");GGGGGG
// 方法一:
ImageUtls.pressText("我是水印文字","C:/Users/apple/Desktop/liupeng.png","C:/Users/apple/Desktop/liupeng11.png","宋体",Font.BOLD,Color.blue,20, 0, 0, 0.5f);//测试OK
// 方法二:
ImageUtls.pressText2("我也是水印文字", "C:/Users/apple/Desktop/liupeng.png","C:/Users/apple/Desktop/liupeng22.png", "黑体", 36, Color.blue, 50, 100,100, 0.5f);//测试OK
String str = "data:image/png;base64,"+imageToBase64("C:/Users/apple/Desktop/liupeng11.png");
String newStr = "data:image/png;base64,"+imageToBase64("C:/Users/apple/Desktop/liupeng22.png");
System.out.println("sdasdasd:"+str);
System.out.println("asdasd"+newStr);
//1.base64保存为图片 2.加水印 3.生成新的base64串
}*/
/**
* 缩放图像(按比例缩放)
* @param srcImageFile 源图像文件地址
* @param result 缩放后的图像地址
* @param scale 缩放比例
* @param flag 缩放选择:true 放大; false 缩小;
*/
public final static void scale(String srcImageFile, String result,
int scale, boolean flag) {
try {
BufferedImage src = ImageIO.read(new File(srcImageFile)); // 读入文件
int width = src.getWidth(); // 得到源图宽
int height = src.getHeight(); // 得到源图长
if (flag) {// 放大
width = width * scale;
height = height * scale;
} else {// 缩小
width = width / scale;
height = height / scale;
}
Image image = src.getScaledInstance(width, height,
Image.SCALE_DEFAULT);
BufferedImage tag = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
Graphics g = tag.getGraphics();
g.drawImage(image, 0, 0, null); // 绘制缩小后的图
g.dispose();
ImageIO.write(tag, "JPEG", new File(result));// 输出到文件流
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 缩放图像(按高度和宽度缩放)
* @param srcImageFile 源图像文件地址
* @param result 缩放后的图像地址
* @param height 缩放后的高度
* @param width 缩放后的宽度
* @param bb 比例不对时是否需要补白:true为补白; false为不补白;
*/
public final static void scale2(String srcImageFile, String result, int height, int width, boolean bb) {
try {
double ratio = 0.0; // 缩放比例
File f = new File(srcImageFile);
BufferedImage bi = ImageIO.read(f);
Image itemp = bi.getScaledInstance(width, height, bi.SCALE_SMOOTH);
// 计算比例
if ((bi.getHeight() > height) || (bi.getWidth() > width)) {
if (bi.getHeight() > bi.getWidth()) {
ratio = (new Integer(height)).doubleValue()
/ bi.getHeight();
} else {
ratio = (new Integer(width)).doubleValue() / bi.getWidth();
}
AffineTransformOp op = new AffineTransformOp(AffineTransform
.getScaleInstance(ratio, ratio), null);
itemp = op.filter(bi, null);
}
if (bb) {//补白
BufferedImage image = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
Graphics2D g = image.createGraphics();
g.setColor(Color.white);
g.fillRect(0, 0, width, height);
if (width == itemp.getWidth(null))
g.drawImage(itemp, 0, (height - itemp.getHeight(null)) / 2,
itemp.getWidth(null), itemp.getHeight(null),
Color.white, null);
else
g.drawImage(itemp, (width - itemp.getWidth(null)) / 2, 0,
itemp.getWidth(null), itemp.getHeight(null),
Color.white, null);
g.dispose();
itemp = image;
}
ImageIO.write((BufferedImage) itemp, "JPEG", new File(result));
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 图像切割(按指定起点坐标和宽高切割)
* @param srcImageFile 源图像地址
* @param result 切片后的图像地址
* @param x 目标切片起点坐标X
* @param y 目标切片起点坐标Y
* @param width 目标切片宽度
* @param height 目标切片高度
*/
public final static void cut(String srcImageFile, String result,
int x, int y, int width, int height) {
try {
// 读取源图像
BufferedImage bi = ImageIO.read(new File(srcImageFile));
int srcWidth = bi.getHeight(); // 源图宽度
int srcHeight = bi.getWidth(); // 源图高度
if (srcWidth > 0 && srcHeight > 0) {
Image image = bi.getScaledInstance(srcWidth, srcHeight,
Image.SCALE_DEFAULT);
// 四个参数分别为图像起点坐标和宽高
// 即: CropImageFilter(int x,int y,int width,int height)
ImageFilter cropFilter = new CropImageFilter(x, y, width, height);
Image img = Toolkit.getDefaultToolkit().createImage(
new FilteredImageSource(image.getSource(),
cropFilter));
BufferedImage tag = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = tag.getGraphics();
g.drawImage(img, 0, 0, width, height, null); // 绘制切割后的图
g.dispose();
// 输出为文件
ImageIO.write(tag, "JPEG", new File(result));
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 图像切割(指定切片的行数和列数)
* @param srcImageFile 源图像地址
* @param descDir 切片目标文件夹
* @param rows 目标切片行数。默认2,必须是范围 [1, 20] 之内
* @param cols 目标切片列数。默认2,必须是范围 [1, 20] 之内
*/
public final static void cut2(String srcImageFile, String descDir,
int rows, int cols) {
try {
if(rows<=0||rows>20) rows = 2; // 切片行数
if(cols<=0||cols>20) cols = 2; // 切片列数
// 读取源图像
BufferedImage bi = ImageIO.read(new File(srcImageFile));
int srcWidth = bi.getHeight(); // 源图宽度
int srcHeight = bi.getWidth(); // 源图高度
if (srcWidth > 0 && srcHeight > 0) {
Image img;
ImageFilter cropFilter;
Image image = bi.getScaledInstance(srcWidth, srcHeight, Image.SCALE_DEFAULT);
int destWidth = srcWidth; // 每张切片的宽度
int destHeight = srcHeight; // 每张切片的高度
// 计算切片的宽度和高度
if (srcWidth % cols == 0) {
destWidth = srcWidth / cols;
} else {
destWidth = (int) Math.floor(srcWidth / cols) + 1;
}
if (srcHeight % rows == 0) {
destHeight = srcHeight / rows;
} else {
destHeight = (int) Math.floor(srcWidth / rows) + 1;
}
// 循环建立切片
// 改进的想法:是否可用多线程加快切割速度
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
// 四个参数分别为图像起点坐标和宽高
// 即: CropImageFilter(int x,int y,int width,int height)
cropFilter = new CropImageFilter(j * destWidth, i * destHeight,
destWidth, destHeight);
img = Toolkit.getDefaultToolkit().createImage(
new FilteredImageSource(image.getSource(),
cropFilter));
BufferedImage tag = new BufferedImage(destWidth,
destHeight, BufferedImage.TYPE_INT_RGB);
Graphics g = tag.getGraphics();
g.drawImage(img, 0, 0, null); // 绘制缩小后的图
g.dispose();
// 输出为文件
ImageIO.write(tag, "JPEG", new File(descDir
+ "_r" + i + "_c" + j + ".jpg"));
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 图像切割(指定切片的宽度和高度)
* @param srcImageFile 源图像地址
* @param descDir 切片目标文件夹
* @param destWidth 目标切片宽度。默认200
* @param destHeight 目标切片高度。默认150
*/
public final static void cut3(String srcImageFile, String descDir,
int destWidth, int destHeight) {
try {
if(destWidth<=0) destWidth = 200; // 切片宽度
if(destHeight<=0) destHeight = 150; // 切片高度
// 读取源图像
BufferedImage bi = ImageIO.read(new File(srcImageFile));
int srcWidth = bi.getHeight(); // 源图宽度
int srcHeight = bi.getWidth(); // 源图高度
if (srcWidth > destWidth && srcHeight > destHeight) {
Image img;
ImageFilter cropFilter;
Image image = bi.getScaledInstance(srcWidth, srcHeight, Image.SCALE_DEFAULT);
int cols = 0; // 切片横向数量
int rows = 0; // 切片纵向数量
// 计算切片的横向和纵向数量
if (srcWidth % destWidth == 0) {
cols = srcWidth / destWidth;
} else {
cols = (int) Math.floor(srcWidth / destWidth) + 1;
}
if (srcHeight % destHeight == 0) {
rows = srcHeight / destHeight;
} else {
rows = (int) Math.floor(srcHeight / destHeight) + 1;
}
// 循环建立切片
// 改进的想法:是否可用多线程加快切割速度
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
// 四个参数分别为图像起点坐标和宽高
// 即: CropImageFilter(int x,int y,int width,int height)
cropFilter = new CropImageFilter(j * destWidth, i * destHeight,
destWidth, destHeight);
img = Toolkit.getDefaultToolkit().createImage(
new FilteredImageSource(image.getSource(),
cropFilter));
BufferedImage tag = new BufferedImage(destWidth,
destHeight, BufferedImage.TYPE_INT_RGB);
Graphics g = tag.getGraphics();
g.drawImage(img, 0, 0, null); // 绘制缩小后的图
g.dispose();
// 输出为文件
ImageIO.write(tag, "JPEG", new File(descDir
+ "_r" + i + "_c" + j + ".jpg"));
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 图像类型转换:GIF->JPG、GIF->PNG、PNG->JPG、PNG->GIF(X)、BMP->PNG
* @param srcImageFile 源图像地址
* @param formatName 包含格式非正式名称的 String:如JPG、JPEG、GIF等
* @param destImageFile 目标图像地址
*/
public final static void convert(String srcImageFile, String formatName, String destImageFile) {
try {
File f = new File(srcImageFile);
f.canRead();
f.canWrite();
BufferedImage src = ImageIO.read(f);
ImageIO.write(src, formatName, new File(destImageFile));
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 彩色转为黑白
* @param srcImageFile 源图像地址
* @param destImageFile 目标图像地址
*/
public final static void gray(String srcImageFile, String destImageFile) {
try {
BufferedImage src = ImageIO.read(new File(srcImageFile));
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
ColorConvertOp op = new ColorConvertOp(cs, null);
src = op.filter(src, null);
ImageIO.write(src, "JPEG", new File(destImageFile));
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 给图片添加文字水印
* @param pressText 水印文字
* @param srcImageFile 源图像地址
* @param destImageFile 目标图像地址
* @param fontName 水印的字体名称
* @param fontStyle 水印的字体样式
* @param color 水印的字体颜色
* @param fontSize 水印的字体大小
* @param x 修正值
* @param y 修正值
* @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
*/
public final static void pressText(String pressText,
String srcImageFile, String destImageFile, String fontName,
int fontStyle, Color color, int fontSize,int x,
int y, float alpha) {
try {
File img = new File(srcImageFile);
Image src = ImageIO.read(img);
int width = src.getWidth(null); //GGGGGG
int height = src.getHeight(null);
BufferedImage image = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
Graphics2D g = image.createGraphics();
g.drawImage(src, 0, 0, width, height, null);
g.setColor(color);
g.setFont(new Font(fontName, fontStyle, fontSize));
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP,
alpha));
// 在指定坐标绘制水印文字
g.drawString(pressText, (width - (getLength(pressText) * fontSize))
/ 2 + x, (height - fontSize) / 2 + y);
g.dispose();
ImageIO.write((BufferedImage) image, "PNG", new File(destImageFile));// 输出到文件流
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 给图片添加文字水印
* @param pressText 水印文字
* @param srcImageFile 源图像地址
* @param destImageFile 目标图像地址
* @param fontName 字体名称
* @param fontStyle 字体样式
* @param color 字体颜色
* @param fontSize 字体大小
* @param x 修正值
* @param y 修正值
* @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
*/
public final static void pressText2(String pressText, String srcImageFile,String destImageFile,
String fontName, int fontStyle, Color color, int fontSize, int x,
int y, float alpha) {
try {
File img = new File(srcImageFile);
Image src = ImageIO.read(img);
int width = src.getWidth(null);
int height = src.getHeight(null);
BufferedImage image = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
Graphics2D g = image.createGraphics();
g.drawImage(src, 0, 0, width, height, null);
g.setColor(color);
g.setFont(new Font(fontName, fontStyle, fontSize));
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP,
alpha));
// 在指定坐标绘制水印文字
g.drawString(pressText, (width - (getLength(pressText) * fontSize))
/ 2 + x, (height - fontSize) / 2 + y);
g.dispose();
ImageIO.write((BufferedImage) image, "JPEG", new File(destImageFile));
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 给图片添加图片水印
* @param pressImg 水印图片
* @param srcImageFile 源图像地址
* @param destImageFile 目标图像地址
* @param x 修正值。 默认在中间
* @param y 修正值。 默认在中间
* @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
*/
public final static void pressImage(String pressImg, String srcImageFile,String destImageFile,
int x, int y, float alpha) {
try {
File img = new File(srcImageFile);
Image src = ImageIO.read(img);
int wideth = src.getWidth(null);
int height = src.getHeight(null);
BufferedImage image = new BufferedImage(wideth, height,
BufferedImage.TYPE_INT_RGB);
Graphics2D g = image.createGraphics();
g.drawImage(src, 0, 0, wideth, height, null);
// 水印文件
Image src_biao = ImageIO.read(new File(pressImg));
int wideth_biao = src_biao.getWidth(null);
int height_biao = src_biao.getHeight(null);
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP,
alpha));
g.drawImage(src_biao, (wideth - wideth_biao) / 2,
(height - height_biao) / 2, wideth_biao, height_biao, null);
// 水印文件结束
g.dispose();
ImageIO.write((BufferedImage) image, "JPEG", new File(destImageFile));
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 计算text的长度(一个中文算两个字符)
* @param text
* @return
*/
public final static int getLength(String text) {
int length = 0;
for (int i = 0; i < text.length(); i++) {
if (new String(text.charAt(i) + "").getBytes().length > 1) {
length += 2;
} else {
length += 1;
}
}
return length / 2;
}
/**
* @Descriptionmap 将图片文件转化为字节数组字符串,并对其进行Base64编码处理
* @author temdy
* @Date 2015-01-26
* @param path 图片路径
* @return
*/
public static String imageToBase64(String path) {// 将图片文件转化为字节数组字符串,并对其进行Base64编码处理
byte[] data = null;
// 读取图片字节数组
try {
InputStream in = new FileInputStream(path);
data = new byte[in.available()];
in.read(data);
in.close();
} catch (IOException e) {
e.printStackTrace();
}
// 对字节数组Base64编码
BASE64Encoder encoder = new BASE64Encoder();
return encoder.encode(data);// 返回Base64编码过的字节数组字符串
}
/**
* @Descriptionmap 对字节数组字符串进行Base64解码并生成图片
* @author temdy
* @Date 2015-01-26
* @param base64 图片Base64数据
* @param path 图片路径
* @return
*/
public static boolean base64ToImage(String base64, String path) {// 对字节数组字符串进行Base64解码并生成图片
if (base64 == null){ // 图像数据为空
return false;
}
BASE64Decoder decoder = new BASE64Decoder();
try {
// Base64解码
byte[] bytes = decoder.decodeBuffer(base64);
for (int i = 0; i < bytes.length; ++i) {
if (bytes[i] < 0) {// 调整异常数据
bytes[i] += 256;
}
}
// 生成jpeg图片
OutputStream out = new FileOutputStream(path);
out.write(bytes);
out.flush();
out.close();
return true;
} catch (Exception e) {
return false;
}
}
}
转载自原文链接, 如需删除请联系管理员。
原文链接:火云邪神的拖鞋图片处理水印二次操刀,这是真jB复杂,还是我太菜,转载请注明来源!