-
I use common dialog to go to any folder and select a
gif or jpg file to be moved into my image folder for later view via a pic display. Is there a way to get the properties of the picture file before I move it...I am concerned with the width and hight of the picture and it
will be only jpg or gif.
ie..
if (selected picture).width > my size _
or (selected picture).height > my size then
msgbox...sorry picture is too large for program
exit
endif
-
You can load it up in a hidden ImageBox and then check the Width and Height properties for it, then unload it and tell wheather it's too big or not.
-
this works for gif's, don't know about jpg though, I can't remember who wrote this it wasn't me, full credit to who ever it was.
Function LoadImageData(FName As String) As String
Dim Temp As String
On Error GoTo FErrorLabel
Open FName For Binary Access Read As #2
Temp = String(FileLen(FName), Chr(0))
Get #2, , Temp
Close #2
LoadImageData = Temp
On Error GoTo 0
Exit Function
FErrorLabel:
LoadImageData = ""
MsgBox "File not found: " & FName
On Error GoTo 0
End Function
to actually call it and find out the info
Private Sub Command1_Click()
tempinfo = LoadImageData("C:\yourgifhere.gif")
MsgBox "Image Width: " & Asc(Right(Left(tempinfo, 7), 1))
MsgBox "Image Height: " & Asc(Right(Left(tempinfo, 9), 1))
End Sub
but you are better to use Megatron's suggestion its a much easier way of doing it.
-
OK
sounds like a plan...thanks both