批处理判断图片像素并整理图片

来源:百度知道 编辑:UC知道 时间:2024/06/24 18:33:57
在一个文件夹里有很多大大小小不同的图片..我想做一个批处理..
1.把图片分辨率横竖都小于300的放到一个文件夹里..
2.把图片横分辨率大于300.竖分辨率小于300的放到一个文件夹里
2.把图片竖分辨率大于300.横分辨率小于300的放到一个文件夹里
1.把图片分辨率横竖都大于300的放到一个文件夹里..
批处理能做到吗?得到的文件我要用ps进行批处理的.大大帮帮忙啊!!!

可以
Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
Dim a As String, k As Single
Private Type BITMAP
bmType As Long
bmWidth As Long
bmHeight As Long
bmWidthBytes As Long
bmPlanes As Integer
bmBitsPixel As Integer
bmBits As Long
End Type

Private Type PicInfo
PicWidth As Long
picHeight As Long
End Type

Private Function fncGetInfo(lsPicName As String) As PicInfo
'lsPicName是图片的文件名,带路径
Dim hBitmap As Long
Dim res As Long
Dim bmp As BITMAP
res = GetObject(LoadPicture(lsPicName).Handle, Len(bmp), bmp) '取得BITMAP的结构
fncGetInfo.PicWidth = bmp.bmWidth '图片的宽
fncGetInfo.picHeight = bmp.bmHeight '图片的高
End Function

取出高和宽后就可以处理图片了

用dir()可以遍历文件夹里的文件

这个问题,用批处理实现