Glynn Clements wrote:
>
> holotko wrote:
>
> > This is very simple however, is there an relativly easy,
> > straightforward way to determine whether or not the file in question
> > is an image file? By determining whether the file is an image file or
> > not I mean specifically something more elegant than merely examining
> > the file name for a "jpg" or "gif" extension.
>
> Look at the first few bytes of the file. A GIF file will start with
> the bytes `GIF87a' or `GIF89a'. A JPEG file will have the bytes `JFIF'
> at offset 6.
>
> However, you should generally use the extension instead. Not only is
> it faster than opening every file, but the extension indicates whether
> the file is meant to be treated as a GIF or JPEG. It's possible that
> some other type of file could contain the above byte sequences by
> coincidence.
>
> --
> Glynn Clements <[EMAIL PROTECTED]>
Thanks for the help. I wound up doing as you suggested and simply
checking file extensions. Now and then however image files such as
jpegs may have different extensions, or no extension, thus my concern
for some methodology other than checking for file extensions. However,
in the environment that this program will be used the majority of such
files are stored with the proper "jpg" extension, thus there should be
no problem.
/John <[EMAIL PROTECTED]>
--
email: [EMAIL PROTECTED]
Local mailserver <landreau.ruffe.edu> , remote <ns.computer.net>
Winston tastes good like a cigarette should!