1 Star 0 Fork 203

glpyh / imagetool

forked from 小帅丶 / imagetool 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

作者

       ├── cn.xsshome.imagetool            //包名
       ├── convert                               
       │       └── ImageToChar             //图片转字符图片、文本方法  
       ├── util        
       │       └── AnimatedGifEncoder      //GIF所需工具类代码
       │       └── Base64Util              //图片数据转base64编码工具类     
       │       └── GifDecoder              //Gif图片处理工具类代码
       │       └── GifImageUtil            //GIF图片添加文字特效工具类代码  
       │       └── LZWEncoder              //图片处理所需工具类代码
       │       └── MergeImageUtil          //图片特效合并工具类代码
       │       └── NeuQuant                //图片处理所需工具类代码
       │       └── PngColoringUtil         //透明图片增加背景色工具类代码
       │       └── RotateImageUtil         //图片旋转工具类代码
       ├── zoom   
       └──     └── ImageHelper             //图片缩放工具类代码 

示例代码

public class Sample {
	public static void main(String[] args) throws Exception {
		ImageToChar.load("G:/phone.jpg", "F:/gif/woman.txt");//静态图片转字符保存为txt文件
		ImageToChar.loadGif("C:/Users/Administrator/Desktop/页面录屏显示.gif", "F:/gif/");//动图转为动态的字符图片
		BufferedImage bi = null;
		bi = ImageIO.read(new File("G:/body.jpg"));
        String bytePic = ImageToChar.txtToImageByBase64(bi);//静态图转字符 返回转换后图片的base64
        System.out.println(bytePic);
	}
}

透明图片增加背景色示例代码

    public static void main(String[] args) throws Exception{
        String image = "F:\\testimg\\1011.png";//原始图片路径
        String resultImage = "F:\\testimg\\10111700.jpg";//处理后保存的图片路径
        changePNGBackgroudColor(image,resultImage, Color.pink);//Color.pink 即图片背景颜色
    }

图片旋转示例代码

public class RotateSample {
    public static void main(String[] args) throws  Exception {
        long start = System.currentTimeMillis();
        BufferedImage src = ImageIO.read(new File("E:\\testimg\\glassess.png"));//原图片本地路径
        BufferedImage des = RotateImageUtil.rotateImage(src,20);//旋转的角度
        ImageIO.write(des, "png", new File("E:\\testimg\\glassess2.png"));//旋转后保存的图片
        long end = System.currentTimeMillis();
        System.out.println("开始时间:" + start+ "; 结束时间:" + end+ "; 总共用时:" + (end - start) + "(ms)");
    }
}

GIF图片加文字特效示例代码

    public static void main(String[] args) throws Exception {
        GifImageUtil gifImageUtil = new GifImageUtil();
        String imagesavePath  = "C:\\Users\\xiaoshuai\\Desktop";//图片保存路径
        String imagesaveName = String.valueOf(System.currentTimeMillis());//图片保存名称 不包含后缀名
        String image  = "C:\\Users\\xiaoshuai\\Desktop\\db.gif";//原始图片
        String result = gifImageUtil.gifAddText(imagesavePath,imagesaveName,"微软雅黑",25,Color.pink,image,"图片添加文字","测试一下","1234","4567");
        System.out.println(result);
    }

白底图片转换透明底图片示例代码

    public static void main(String[] args) {
        System.out.println(PngConvertUtil.transparentImg("F:/testimg/hand.jpg", "F:/testimg/hand2020.png"));
    }

GIF图片加文字特效示例图

原始图

原始图

转换图

转换图

给图片指定区域增加矩形框

原始图

原始图

转换图

转换图

给透明图片增加背景图

    public static void main(String[] args) throws Exception{
        //最好保证宽或高一致  
        BufferedImage src = ImageIO.read(new File("F:\\testimg\\gjy2.jpg"));//背景图
        BufferedImage png = ImageIO.read(new File("F:\\testimg\\banner.png"));//透明图
        BufferedImage image = MergeImageUtil.mergePendant(src, png, 0, 0, 1);
        File file = new File("F:\\testimg\\banner320.jpg");//输出图片路径
        ImageIO.write(image, "jpg", file);
    }

原始图

透明图

透明图

背景图

背景图

效果图

效果图

MIT License Copyright (c) 2020 小帅丶 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

图片转字符图片工具类,支持 Gif 动画。详情请看 展开 收起
Java
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/glpyh/imagetool.git
git@gitee.com:glpyh/imagetool.git
glpyh
imagetool
imagetool
master

搜索帮助

14c37bed 8189591 565d56ea 8189591