以 jpeg 格式保存色彩空间
我有一个 servlet 来转换和缓存较小版本的照片。它是使用 java.awt.image + javax.imageio 和第三方重采样过滤器实现的。原件均使用 sRGB 颜色配置文件上传。当我重新采样并再次保存它们时,它们仍然处于 sRGB 格式,但这不会记录在保存的文件中。
我如何确保此信息已保存在文件中?
如果您想知道它有什么不同,没有配置文件的图像在我的屏幕(Safari + OSX + 校准屏幕)上比具有正确的 sRGB 配置文件时更加饱和。我也确信这是丢失的配置文件信息,而不是重采样算法。
I have a servlet to convert and cache smaller versions of photographs. It is implemented using java.awt.image + javax.imageio and a third party resample filter. The originals are all uploaded with an sRGB color profile. When I resample them and save them again they still are in sRGB however this is not recorded in the saved file.
How can I make sure this information is saved in the file?
In case you wondered it makes a difference, images without a profile are much more saturated on my screen (Safari + OSX + Calibrated screen) then when they have the correct sRGB profile. Also I'm sure it's the missing profile information and not the resampling algorithm.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,包含一个 EXIF 标签 ColorSpace=1 就足够了,它告诉它应该作为 sRGB 进行处理。使用 Apache Commons Sanselan 成功做到了这一点。不幸的是,这个库并不完整,因此它只能用于在文件创建后修改 EXIF。
相关代码,基于Sanselan示例:
Turns out it is enough to include an EXIF tag ColorSpace=1 that tells it should be processed as sRGB. Succeeded into doing this using Apache Commons Sanselan. This library is unfortunatly not complete so it can only be used to modify the EXIF after the file has been created.
Relevant code, based on Sanselan example: