bdzot
asked on
Is there a quick and easy way to determine if a file is an image?
Howdy, all,
I received images in the course of a normal day. However, the files do not have normal extensions (".aaa", ".aab", ".aac", etc instead of ".gif", ".jpg", ".tif", etc) and are intermixed with non-image files in an archive.
I'm writing an app that will extract and display the images, but I want to weed out the non-image files from the directory list.
Does vb.net have a quick and easy way to determine if a file is a displayable image or not?
Thanks in advance.
I received images in the course of a normal day. However, the files do not have normal extensions (".aaa", ".aab", ".aac", etc instead of ".gif", ".jpg", ".tif", etc) and are intermixed with non-image files in an archive.
I'm writing an app that will extract and display the images, but I want to weed out the non-image files from the directory list.
Does vb.net have a quick and easy way to determine if a file is a displayable image or not?
Thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Unfortunately, .bmp is one of the formats I don't deal with.
However, this worked:
Private Function isValid(ByVal imagePath as string) as Boolean
Dim valid as Boolean
Dim imageFile as Image
Try
imageFile = Image.FromFile(imagePath)
valid = True
Catch ex As Exception
valid = false
Finally
imageFile = Nothing
End Try
Return valid
End Function
Much thanks!