Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is their a method for GETting Image formats?

Status
Not open for further replies.

Kruzer

Programmer
Jun 16, 2000
117
US
I'm trying to find a method that gets the image format of an image, kinda of a test to see what file format is coming through the program.

I found so far an exception 'ImageFormatException'

Signals that an Image Format exception of some sort has occurred

Perl has a method called $image->Get('format'); Anything in Java that does this? [sig]<p>Dano<br><a href=mailto:dskryzer@hotmail.com>dskryzer@hotmail.com</a><br><a href= </a><br>What's your major malfunction[/sig]
 
There might be but I don't know of any simple built in function like the perl one. You could try just reading the header of the file.
gifs are usually: &quot;GIF89a&quot; or &quot;GIF87a&quot;
bitmaps: &quot;BM8&quot; is one of them
jpgs: 255,216,255,224 (first four bytes)
etc.
Although that would be pretty manual and you'd have to read up on it. Sorry for making this suggestion if it turns out there's an easier way.
Are you trying to detect what the format is or whether the format is valid? [sig]<p>--Will Duty<br><a href=mailto:wduty@radicalfringe.com>wduty@radicalfringe.com</a><br><a href= > </a><br> [/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top