以编程方式选择图像转换格式为 JPEG 或 PNG 以用于 Silverlight 显示
我有一个项目,需要转换大量图像类型以在 Silverlight 应用程序中显示 - TIFF、GIF、WMF、EMF、BMP、DIB 等。我可以在水合 Silverlight 应用程序之前在服务器上执行这些转换。
但是,我不确定何时应该选择转换为哪种格式,JPG 还是 PNG。是否有某种标准,例如 TIFF 应该始终是 JPEG,GIF 应该始终是 PNG。或者,如果 BMP 是 24 位,则应将其转换为 JPEG - 任何更低的位,也可以是 PNG。或者一切都是 PNG,为什么?
我通常看到或看到针对此类问题的回答是“< em>好吧,如果图片是照片,请使用 JPEG”或“如果有直线,则使用 PNG 更好。”不幸的是,我根本没有机会查看任何图像文件,并且只想通过代码执行此操作的标准方法,即使这是无数的 if/then 语句。
是否有围绕此主题的任何标准或最佳实践?
I have a project where I need to convert a large number of image types to be displayable in a Silverlight app - TIFF, GIF, WMF, EMF, BMP, DIB, etc. I can do these conversions on the server before hydrating the Silverlight app.
However, I'm not sure when I should choose to convert to which format, either JPG or PNG. Is there some kind of standard out there like TIFF should always be a JPEG and GIF should always be a PNG. Or, if a BMP is 24 bit, it should be converted to a JPEG - any lower and it can be a PNG. Or everything is a PNG and why?
What I usually see or see in response to this type of question is "Well, if the picture is a photograph, go with JPEG" or "If it has straight lines, PNG is better." Unfortunately, I won't have the luxury of viewing any of the image files at all and would like just a standard way to do this via code, even if that is a zillion if/then statements.
Are there any standards or best practices around this subject?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
可能起作用的最简单的事情是“保留所有细节”(“100% 质量”) ,即始终使用 PNG 而不是 JPEG。
PNG 图像看起来总是与原始图像相同(无损)。
JPG 图像通常看起来与原始图像大致相同,但在某些图像(例如线条艺术)上,JPG 会产生奇怪的压缩伪影(有损)。
The simplest thing that could possibly work is "keep all the detail" ("100% quality"), i.e., always use PNG rather than JPEG.
PNG images always look identical to the original (it is lossless).
JPG images usually look about the same as the original, but on some images (such as line art) JPG gives weird compression artifacts (it is lossy).
与 PNG 相比,JPG 的一大优势是 JPG 在图片大小和质量之间提供了良好的平衡。如果文件大小不是问题,那么 PNG 可能是最佳选择,因为它比 JPG 提供更多的灵活性。但这并不能真正回答你的问题。
One big advantage of JPG over PNG is that JPGs provide a good balance between picture size and quality. If file size isn't a concern then PNG is probably the way to go as it offers more flexibility than JPG. This doesn't really answer your question, though.
您可以使用 Smush.it 之类的服务 - 它会告诉您最佳的优化格式图像,并为您运行压缩。
如果我没记错的话,他们对每个图像运行所有压缩,然后比较结果......返回最好的一组图像。
You can use a service like Smush.it - it will tell you the best optimized format for the images, and run the compressions for you.
If I recall correctly, they run all compressions on each image, then compare the outcomes... returning the best of the set.