converting bmp to jpg in java

旧街凉风 提交于 2019-12-02 01:49:39

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/10837292/converting-bmp-to-jpg-in-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!