KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm loading an image from a file, and I want to know how to validate the image before it is fully read from the file. string filePath = "image.jpg"; Image newImage = Image.FromFile(filePath); The problem occurs when image.jpg isn't really a jpg. For example, if I create an empty text file and rename it to image.jpg, an OutOfMemory Exception will be thrown when image.jpg is loaded. I'm looking for a function that will validate an image given a stream or a file path of the image. Example function prototype bool IsValidImage(string fileName); bool IsValidImage(Stream imageStream);
Tags (comma-separated)
Save Edits
Cancel