仅在一个特定的 JPEG 文件上将 PNG 合成到 JPEG 失败(颜色全部渲染为黑色)
我正在构建一个应用程序,它使用 Ruby+RMagick 将 PNG 图像合成到各种 JPEG 背景上。一切正常,但是我们发现了一个特定的 JPEG 背景,其中 PNG 被合成为黑点。 PNG 透明度受到尊重; “斑点”的形状是正确的,但颜色正在丢失并变成黑色。
我尝试了很多 JPEG,试图找到另一个产生相同结果的 JPEG,但(到目前为止)都失败了。
我怀疑这可能与相关 JPEG 文件的位深度或其他一些参数有关。我一直在互联网上搜索,寻找一个可以分析这个 JPEG 并告诉我所有可能相关的参数的工具,但还没有找到任何东西。
- 你有遇到过这样的事情吗?原因是什么?
- 根据您对 JPEG 格式的了解,是否还有其他可能相关的参数?
- 你知道有什么工具可以分析 JPEG 文件,并告诉我位深度和其他参数吗?或者,如果我在十六进制编辑器中打开 JPEG,你能告诉我如何找到这些信息吗?
I'm building an application which uses Ruby+RMagick to composite PNG images onto various JPEG backgrounds. Everything is working, but we have found one particular JPEG background for which the PNG is composited as a black spot. PNG transparency is respected; the shape of the "spot" is correct, but the colors are being lost and becoming black.
I have tried many JPEGs to try to find another which yields the same result, but (so far) have failed.
I suspect that it may have something to do with the bit depth or some other parameter of the JPEG file in question. I have been searching the Internet, looking for a tool which can analyze this JPEG and tell me all the parameters which might be relevant, but haven't found anything yet.
- Has anything like this ever happened to you? What was the cause?
- Based on your knowledge of the JPEG format, are there any other parameters which might be relevant?
- Do you know of any tool which can analyze JPEG files, and tell me the bit depth and other parameters? Or if I open the JPEG in a hex editor, can you tell me how to find this information?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我仍然没有发现复合操作无法正常工作的那张 JPG 有什么特别之处,但我使用以下代码解决了它:
而不是:
I still haven't found what is special about that one JPG which the composite operation doesn't work correctly on, but I worked around it using this code:
Rather than: