From: Doug Schwarz on
In article
<1d6dfc1f-9b4e-4587-b0f9-111d24fb6690(a)f8g2000vba.googlegroups.com>,
ImageAnalyst <imageanalyst(a)mailinator.com> wrote:

> Like others suggested, you can use fileparts() to extract the
> extension and then switch on it. On rare occasions, the extension is
> wrong and the file actually contains a different type of image. In
> that case, you can often check the first two bytes of the file using
> fread(). For example, if it's a BMP the bytes will be BM, if it's
> tiff they'll be II or MM, and if it's JPEG they'll FFD8 (in hex),
> etc. Some programs will handle incorrect extensions, but some will
> just throw an exception saying that the file doesn't agree with the
> extension.


Why not use imfinfo?

--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.