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

时间:2009-04-16 22:15:49

标签: vb.net

我正在使用下面的代码读取图像(jpg),我需要检查图像是否大于150像素×150像素且小于25k,我应该怎么做?

PictureBox2.Image = Image.FromFile(.FileName)

1 个答案:

答案 0 :(得分: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