VB.NET如何检查图像的大小和尺寸?

问题描述 投票:1回答:1

我使用下面的代码读取图像(JPG格式),我需要检查图像是不大于150像素×150个像素,并且小于25K,我应该怎么办呢?

PictureBox2.Image = Image.FromFile(.FileName)
vb.net
1个回答
7
投票
If New FileInfo(.FileName).Length > 25 * 1024 Then ... 'More than 25KB'
Dim img = Image.FromFile(.FileName)
If img.Size.Width > 150 OrElse img.Size.Height > 150 Then ... 'More than 150x150'
Picturebox1.Image = img
© www.soinside.com 2019 - 2024. All rights reserved.