|
Posted by Peter Ludikovsky on January 15, 2008, 7:56 am
Please log in for more thread options
Thomas Armstrong wrote:
> Hi.
>
> I'm trying to create a Perl script which converts all files within a
> directory into JPEG format. First, I read them using two lines
> detecting extension (.jpg, .png, ...) but sometimes these files are
> wrong and get this error message:
> -----
> gd-jpeg: JPEG library reports unrecoverable error: Not a JPEG file:
> starts with 0x89 0x50
> ---------
>
> Is there any method to get image type?
> e.g.: GD::Image->getImageType("myfile.jpg")
>
> Thank you very much.
>
a) Invoke the divine powers of file(1)
b) open the file & read the identifying characters [0][1][2]...
c) use File::Type;
HTH
/peter
[0] http://filext.com/file-extension/PNG [1] http://filext.com/file-extension/GIF [2] http://filext.com/file-extension/JPG
|