473,566 Members | 2,958 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6766
Dim b As Bitmap
Try
b = Bitmap("c:\imag e.jpg")
Catch ex As Exception
MessageBox.Show ("Error")
End Try

Igor Stanek

"Christophe r Kurtis Koeber" <c_******@myrea lbox.com> wrote in message
news:uh******** ******@TK2MSFTN GP15.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:\imag e.jpg")
Catch ex As Exception
MessageBox.Show ("Error")
End Try

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



Igor Stanek

"Christophe r Kurtis Koeber" <c_******@myrea lbox.com> wrote in message
news:uh******** ******@TK2MSFTN GP15.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******** ******@TK2MSFTN GP14.phx.gbl...
Dim b As Bitmap
Try
b = Bitmap("c:\imag e.jpg")
Catch ex As Exception
MessageBox.Show ("Error")
End Try

Igor Stanek

"Christophe r Kurtis Koeber" <c_******@myrea lbox.com> wrote in message
news:uh******** ******@TK2MSFTN GP15.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
19365
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 from the image. I can subsequently display the JPG image itself, but the thumbnail creation fails. I have tried this with hundreds of other images...
7
7561
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 and views it aswell as infomation. The program also has a JTextFiels which allows the user to enter the M number. The problem i have is checking that...
5
2990
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 - A Proposal As we all know, one of the best things about python and other scripting languages is dynamic typing (yes I know it has advantages...
2
1795
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 frameset in the opener window. I started with something like this (what happens when the considions are met already works):
5
11040
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 something called stringstreams to do the conversion. Here's my C version, can I leave it as it is or does it need to be robustified or changed in...
2
2136
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 I know wheater the URL is valid? I use a Image webcontrol and that doesn't let me know the picture cannot be found, it just shows the red x.
6
2975
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 of them have worked. Any Ideas? ------------------------ $imgCheck=readfile("http.//www.somesite.com/image.gif"); if($imgCheck) echo "<img...
1
2692
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 class MyImage { //data member image
125
6505
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 problem. http://www.jilp.org/vol9/v9paper10.pdf Specifically, they measured the overhead of a bounds
0
7673
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7893
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8109
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7953
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6263
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2085
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1202
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.