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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

determining image file types

Status
Not open for further replies.

torturedmind

Programmer
Jan 31, 2002
1,052
PH
every once in a while, our clients send us image files without their extension name (.jpg, .gif, .bmp, whatever). this means that only the filename itself will be left untouched. am wondering, is there some way to determine the image file's type so that the program can save it on a temporary location and then load it in it's default application? like, if the program determined that it's a bmp, then it will save it in, say, c:\windows\temp with the extension .bmp and then load the file in ms paint.

i will be grateful for any help you guys can extend. peace! [peace]

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
i forgot to mention, we're using vfp6 on a win98se platform. thanks again.

peace! [peace]

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
The first, that comes to - try to read file header by VFP file low level functions, for example:
Code:
lnHandle = FOPEN("disk_letter:\some_directory\some_file_without_extension")
lcString= FREAD(nHandle,3) && gif-file have leftmost 3 symbols = "GIF"
? lcString
=FCLOSE(lnHandle)
BMP leftmost 2 symbols are BM
etc

Juri Shutenko
Municipality of Maardu, Estonia
 
Following Juris's tip:

%PDF - first four characters of a .pdf file
GIF - first three of a .gif
II* - first three of a .tif
FF D8 FF - Hex values of first three characters of a .jpg

Hope this helps

Regards

Griff
Keep [Smile]ing
 
thanks guys. i'll try this later. peace! [peace]

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top