图片类型转换,如png转换为jpg
来源:互联网 发布:淘宝店铺隐藏优惠券 编辑:程序博客网 时间:2024/05/16 08:29
package com.github.elizabetht.controller;import java.awt.Color;import java.awt.image.BufferedImage;import java.io.File;import java.io.IOException;import javax.imageio.ImageIO;public class ConvertImageFile { public static void main(String[] args) { BufferedImage bufferedImage; try { //read image file bufferedImage = ImageIO.read(new File("c:\\a.png")); //conver BufferedImage newBufferedImage = toOpaqueImage(bufferedImage); // write to jpeg file ImageIO.write(newBufferedImage, "jpg", new File("c:\\b.jpg")); System.out.println("finished"); } catch (IOException e) { e.printStackTrace(); } } public static BufferedImage toOpaqueImage(BufferedImage input){ //set color return toOpaqueImage(input,Color.WHITE); } /** * * @param input source * @param bgColor backgroundColor * @return */ public static BufferedImage toOpaqueImage(BufferedImage input,Color bgColor){
//create a blank, RGB, same width and height, and a white background
BufferedImage output=new BufferedImage(input.getWidth(), input.getHeight(), BufferedImage.TYPE_INT_RGB); output.createGraphics().drawImage(input, 0, 0, input.getWidth(), input.getHeight(), bgColor, null); return output; }}
0 0
- 图片类型转换,如png转换为jpg
- convert jpg转换为png
- Java png 图片 转换成 jpg 图片
- 如何将bitmap 压缩/转换为jpg/png格式的图片存贮
- png jpg图片转换为eps的在线网站,用于LaTeX
- ArcGis把jpg、png格式地图图片转换为tif格式
- Android中将webp格式图片转换为png和jpg(续)
- Ubuntu16.04将.png/.jpg图片转换为.eps/.pdf格式
- Bmp 图片转换为 jpg 图片(delphi)
- C++ BMP图片转换为PNG图片
- ArcGIS10.2服务切片 JPG/PNG 转换为 Bundle/Bundlx
- photoshop 源文件psd 图片 转换格式成jpg、png、gif
- html转换为图片(html to jpg)
- jpg图片转换为avi视频
- php各类图片转换为jpg格式
- 【整理】查看SVG图片,将SVG图片转换为PNG,JPG,TIF等方面的工具或软件
- 图片压缩,输出.png(有可能还是jpg类型,只是后缀为.png而已)
- YUYV转换为jpg
- myeclipse10安装了activiti插件后创建BPMN 文件时报错
- assert用法及实现assert宏
- 微信小程序之页面的跳转
- Dynamics CRM Fetch XML Size Limit
- 昨日买的股票今日大获全胜,今日买的毫发无损,操盘机器人年后至今仅一天失误,超强,雄起
- 图片类型转换,如png转换为jpg
- DenseNet网络结构产生的.py文件出错解决
- gradle构建时跳过指定tests
- Eclipse 转 IntelliJ IDEA历程
- 机器学习中的特征工程总结
- JavaScript正则表达式
- 多线程&多进程解析:Python、os、sys、Queue、multiprocessing、threading
- python进阶-数据结构和算法
- MFC应用程序打包发布教程