C# 生成缩略图文件大小
我有以下代码来拍摄图像并生成缩略图。
如何以编程方式改变质量或压缩以获得更小的文件大小?
Image thumbNail = image.GetThumbnailImage(Width, Height, null, new IntPtr());
I have the following code to take an image and generate the thumbnail.
how can I alter the quality or compression to get smaller file sizes programatically?
Image thumbNail = image.GetThumbnailImage(Width, Height, null, new IntPtr());
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您确实需要更好地控制生成的缩略图,那么您最好通过手动生成较小尺寸和不同质量的图像来生成自己的缩略图。 GetThumbnailImage 不能给你太多的控制权。
请参阅这篇文章了解它是如何完成的。
http://www.switchonthecode.com/教程/csharp-tutorial-image-editing- saving-cropping-and-resizing
If you truly need better control over the thumbnails produced, you will be better off producing your own by manually generating an image of smaller size and different quality. The GetThumbnailImage dows not give you much control.
See this article for how it's done.
http://www.switchonthecode.com/tutorials/csharp-tutorial-image-editing-saving-cropping-and-resizing
使用
Image.Save 保存
您可以通过传递thumbNail
时EncoderParameter
。请参阅:使用 C# 降低 JPEG 图片质量When saving the
thumbNail
withImage.Save
you can specify the quality by passing aEncoderParameter
. See: Reducing JPEG Picture Quality using C#您不使用 GetThumbnailImage API:
You do not use the GetThumbnailImage API: