Java保存原始JPEG没有损失 [英] Java Saving Original JPEG Without Loss

查看:162
本文介绍了Java保存原始JPEG没有损失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如下所示,我将第一张图像作为原始JPEG图像。第二张图像用于缓冲图像,然后使用),但这些是罕见的例外情况。



无论如何,您似乎可以访问原始JPG图片,你不改变它,所以我不明白为什么你再次压缩它。



如果你真的必须存储这些图像无损,最好的选择是使用JPEG2000的无损模式,这比其他交替使用更小的文件大小我喜欢PNG用于使用JPG压缩的图像数据(虽然它仍然比原始JPG大得多)。例如,对于您的第一张示例图片:

  hAw2d.jpg  - > 268,678字节(原始)
hAw2d.jp2 - > 1,021,007字节(JPEG 2000,无损)
hAw2d.png - > 1,213,392字节(PNG)


As can be seen below I have 1st image an original JPEG image .Second one was taken to buffer image and than save using http://www.lac.inpe.br/JIPCookbook/6040-howto-compressimages.jsp with 1.0 quality . Still image became smaller in size and a really small destortion. Is it possible to save image to its quality as it is ? Pleas not that saving image as it is was just a sample test. After adding text I save it with highest quality which looses information too.

解决方案

JPEG, even with highest quality settings, is always lossy, even if the original image data came from a JPEG.

There are some operations like rotation/mirroring/crop that can be done lossless on a JPEG (using tools like jpegtran), but these are rare exceptions.

Anyway, it seems you have access to the original JPG image and you don't change it, so I don't understand why you compress it again.

If you really have to store such images lossless, best choice would be using the lossless mode of JPEG2000, this gives a smaller filesize than other alternatives like PNG for image data that has been compressed using JPG (although it is still much larger than the original JPG). For example, for the first of your example pictures:

 hAw2d.jpg ->   268,678 bytes (Original)
 hAw2d.jp2 -> 1,021,007 bytes (JPEG 2000, lossless)
 hAw2d.png -> 1,213,392 bytes (PNG)

这篇关于Java保存原始JPEG没有损失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆