问题
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