473,406 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Checking for valid image in VB.Net

Dear All,
I am working on an imaging application in Visual Basic.Net and I want
the application to check and see if the image is valid that I am loading so
that my application will not crash when loading the image. For example, if
someone creates a file that is not an JPEG yet it has that extension, how
can I program the application so that it will detect this? Thank you very
much in advance for your time and attention in this matter.
Sincerely,
Christopher Koeber
Nov 21 '05 #1
3 6746
Dim b As Bitmap
Try
b = Bitmap("c:\image.jpg")
Catch ex As Exception
MessageBox.Show("Error")
End Try

Igor Stanek

"Christopher Kurtis Koeber" <c_******@myrealbox.com> wrote in message
news:uh**************@TK2MSFTNGP15.phx.gbl...
Dear All,
I am working on an imaging application in Visual Basic.Net and I want
the application to check and see if the image is valid that I am loading
so that my application will not crash when loading the image. For example,
if someone creates a file that is not an JPEG yet it has that extension,
how can I program the application so that it will detect this? Thank you
very much in advance for your time and attention in this matter.
Sincerely,
Christopher Koeber

Nov 21 '05 #2
Dim b As Bitmap
Try
b = New Bitmap("c:\image.jpg")
Catch ex As Exception
MessageBox.Show("Error")
End Try

"Igor Stanek" <i.***********@chastia.com> wrote in message news:ep**************@TK2MSFTNGP14.phx.gbl...
Dim b As Bitmap
Try
b = Bitmap("c:\image.jpg")
Catch ex As Exception
MessageBox.Show("Error")
End Try



Igor Stanek

"Christopher Kurtis Koeber" <c_******@myrealbox.com> wrote in message
news:uh**************@TK2MSFTNGP15.phx.gbl...
Dear All,
I am working on an imaging application in Visual Basic.Net and I want
the application to check and see if the image is valid that I am loading
so that my application will not crash when loading the image. For example,
if someone creates a file that is not an JPEG yet it has that extension,
how can I program the application so that it will detect this? Thank you
very much in advance for your time and attention in this matter.
Sincerely,
Christopher Koeber


Nov 21 '05 #3
Thanks, a lot, works like a charm!

Christopher
"Igor Stanek" <i.***********@chastia.com> wrote in message
news:ep**************@TK2MSFTNGP14.phx.gbl...
Dim b As Bitmap
Try
b = Bitmap("c:\image.jpg")
Catch ex As Exception
MessageBox.Show("Error")
End Try

Igor Stanek

"Christopher Kurtis Koeber" <c_******@myrealbox.com> wrote in message
news:uh**************@TK2MSFTNGP15.phx.gbl...
Dear All,
I am working on an imaging application in Visual Basic.Net and I want
the application to check and see if the image is valid that I am loading
so that my application will not crash when loading the image. For
example, if someone creates a file that is not an JPEG yet it has that
extension, how can I program the application so that it will detect this?
Thank you very much in advance for your time and attention in this
matter.
Sincerely,
Christopher Koeber


Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Stephen Oakes | last post by:
I am trying to upload an image to a server, but I get this warning: Warning: imagecreatefromjpeg(): 'filename' is not a valid JPEG file The error occurs when I am trying to create a thumbnail...
7
by: - ions | last post by:
I have created a JComboBox with its Items as a list of "M" numbers ie. M1,M2,M3.......throgh too M110 (thes are the messier objects, a catolouge of deep sky objects) the user selects of of these...
5
by: Tongu? Yumruk | last post by:
I have a little proposal about type checking in python. I'll be glad if you read and comment on it. Sorry for my bad english (I'm not a native English speaker) A Little Stricter Typing in Python...
2
by: JPL Verhey | last post by:
(i hope somebody (else) will read and have an idea! Thnx) Hi, With a script in a popup window, I want to check if certain content is present in a page loaded into the frame "main" of the...
5
by: William Payne | last post by:
Hello, I am in the process of converting a C++ program to a C program. The user of the program is supposed to supply an integer on the command line and in the C++ version of the program I was using...
2
by: EMW | last post by:
Hi, My ASPX (vb.NET) page needs to check an URL. if it exists then it shows the picture (url is to that picture) if is doesn't exist, it must show another picture. but the question is how do...
6
by: darthmincho | last post by:
Hi. I want to check if an image exists on a remote server, and if it does, show it. I If it does not exist I want to show a default message. I have previously used these chunks of code but none...
1
by: Martijn Mulder | last post by:
At startup my application loads an image from a file from disk. If the file is not there, I still need a valid System.Drawing.Image object but I don't know how to get one. //class MyImage...
125
by: jacob navia | last post by:
We hear very often in this discussion group that bounds checking, or safety tests are too expensive to be used in C. Several researchers of UCSD have published an interesting paper about this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.