用C#语言处理图片(包括大小和质量等细节)
发布时间
阅读量:
阅读量
采用ImageProcessor nuget包进行操作
代码示例如下
public void ImageCompress()
{
string file = @"C:\Users\Administrator\Pictures\test.jpg";
byte[] photoBytes = File.ReadAllBytes(file);
ISupportedImageFormat format = new JpegFormat { Quality = 35, };
Size size = new Size(150, 150);
using (MemoryStream inStream = new MemoryStream(photoBytes))
{
using (MemoryStream outStream = new MemoryStream())
{
using (ImageFactory imageFactory = new ImageFactory())
{
imageFactory.Load(inStream)
.
全部评论 (0)
还没有任何评论哟~
