//压缩图片
int width = 200;
using (var imgBmp = new Bitmap(@"d:\壁纸\b2.jpg"))
{
//找到新尺寸
int oWidth = imgBmp.Width;
int oHeight = imgBmp.Height;
int height = oHeight;
if (width > oWidth)
{
width = oWidth;
}
else
{
height = width * oHeight / oWidth;
}
var newImg = new Bitmap(imgBmp, width, height);
//保存到本地
newImg.Save("d:/ys_7777.jpg");
newImg.Dispose();
}
.NET Core压缩图片为小尺寸
猜你喜欢
转载自blog.csdn.net/u011511086/article/details/113616213
今日推荐
周排行