How do you convert bmp to jpg in Java? I know how to use the ImageIO way but is there a much faster or better way of doing it?

This is the ImageIO way of doing that I found on the web.

`//Create file for the source

File input = new File("c:/temp/image.bmp");

//Read the file to a BufferedImage

BufferedImage image = ImageIO.read(input);`

//Create a file for the output

File output = new File("c:/temp/image.jpg");

//Write the image to the destination as a JPG

ImageIO.write(image, "jpg", output);

If I use this way will I lose quality?

Thanks

解决方案

Yes you will. Actually regardless of the way to convert a BMP (lossless) to JPG (lossy) you always lose quality. You can limit the damage if you set the JPG quality to 100% (which kind of defeats the purpose in my opinion).

Use this tutorial to fix it.

java bmp转jpg,在java中将bmp转换为jpg相关推荐

  1. 如何在 Java 中将 PDF 转换为图像

    将 PDF 转换为图像是开发人员的常见需求.在Free Spire.PDF的帮助下,我们可以轻松地将任何大小和版本的 PDF 文件转换为 Java 应用程序中的高质量图像.在本文中,我将介绍将 PDF ...

  2. 在Java中将boolean转换为int

    本文翻译自:Convert boolean to int in Java 在Java中将boolean转换为int的最常用方法是什么? #1楼 参考:https://stackoom.com/ques ...

  3. 在Java中将Double转换为Integer

    本文翻译自:Cast Double to Integer in Java Any way to cast java.lang.Double to java.lang.Integer ? 有什么方法可以 ...

  4. 如何在Java中将String转换为int?

    如何在Java中将String转换为int ? 我的字符串仅包含数字,我想返回它代表的数字. 例如,给定字符串"1234" ,结果应为数字1234 . #1楼 好吧,要考虑的一个非 ...

  5. java当前时间转化毫秒_Java中将毫秒转化为日期的方法

    Java中将毫秒转化为日期的方法 将毫秒转化为日期 import java.awt.BorderLayout; import java.awt.Frame;import java.awt.TextAr ...

  6. 如何在Java中将String转换为int

    在本教程中,我们将看到将Java中的String转换为int(或Integer)的各种方法. 您可以使用以下任何一种方式: –使用Integer.parseInt(string) –使用Integer ...

  7. android 字符串 转公式,java – 在android中将字符串转换为bigdecimal

    嗨我怎么能在android中将字符串转换为bigdecimal. 这是我的第一项活动: public class ViewCartActivity extends Activity { String ...

  8. 在Java中将字符串转换为日期,将日期转换为字符串

    Sometimes we have to Convert String to Date in java program or convert Date to String in a different ...

  9. 在Java中将字符串转换为char数组,将char数组转换为String

    Today we will learn how to convert String to a char array and then char array to String in Java. 今天, ...

最新文章

  1. Web前端工程师的一些常见误区
  2. 知识图谱,下一代数据中台的核心技术
  3. 怎么在VS监视DataSet类型的数据
  4. 7.Mybatis关联表查询(这里主要讲的是一对一和一对多的关联查询)
  5. 八皇后问题判断此位置是否需合适
  6. java非递归_Java非递归文件系统走路
  7. 【hue】 Access denied to hive-未解决
  8. 查看电脑wifi密码
  9. 零基础入门神经网络:从原理、主要类型到行业应用
  10. 使用create-react-app添加css modules、sasss和antd
  11. 数据治理--元数据--元数据的作用
  12. Unrecognized Windows Sockets error: 10106: create解决方案
  13. 文件下载和二进制文件(图片、mp4视频)预览响应头的设置(防止中文名名乱码)
  14. 微信h5页面图片预览
  15. ORA-01400错误
  16. 安全技术与相关安全工具
  17. 防止Form表单重复提交的客户端及服务器端的方式
  18. iOS开发 ☞ Cornerstone (SVN)用法详解
  19. 奥比中光 ORBBEC Astra Mini Pro简单使用
  20. 用python画小猪佩奇代码_Python turtle模块实例:绘制小猪佩奇(上)

热门文章

  1. awk工具的简单使用
  2. Windows8之hyper-v探索
  3. hdu 1872 稳定排序
  4. [转]Dynamic and static Rectangle in WPF
  5. 多个服务间多个自定义的ExceptionHandler类的执行顺序
  6. 信息学奥赛一本通 1146:判断字符串是否为回文 | OpenJudge NOI 1.7 33:判断字符串是否为回文
  7. 信息学奥赛一本通 1127:图像旋转 | OpenJudge NOI 1.8 11:图像旋转
  8. 石子合并(洛谷-P1880)
  9. 仙岛求药(信息学奥赛一本通-T1251)
  10. 邮件服务 php,PHP基础-邮件服务