前几天,我问了一个关于how to reduce the size of an image while keeping its ratio's dimensions的问题。我终于能够让它工作了。现在,当用户上传图像时,它的 3 个副本(具有不同的尺寸)将保存到数据库中。
但是,不幸的是,尺寸的减小明显降低了上传图像的质量。只有保存的没有尺寸的副本才能保持其质量。
我应该预料到质量会下降吗?图像看起来真的很糟糕(就像报纸的照片)。
有什么我可以做的吗?我需要在代码中设置一个强大的选项。
感谢您的帮助
最佳答案
原因是因为Image.GetThumbnailImage您正在使用的功能仅用于制作低质量的图像。
请参阅有关 GetThumbnailImage 的 MSDN 文档中的这些注释:
The GetThumbnailImage method works well when the requested thumbnail image has a size of about 120 x 120 pixels. If you request a large thumbnail image (for example, 300 x 300) from an Image that has an embedded thumbnail, there could be a noticeable loss of quality in the thumbnail image. It might be better to scale the main image (instead of scaling the embedded thumbnail) by calling the DrawImage method.
有关如何在 C# 中执行高质量图像缩放的一个很好的示例,请参阅以下问题:
关于C#:为什么减小图像大小会导致图像质量非常差?我可以做任何事,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4306260/