Is it possible to detect the format of a file using ImageMagick?
I would need to detect at least the following formats:
- common image formats (jpg, gif, bmp, tif, tga, etc...)
- common video formats (avi, mpg, etc...)
- common sound formats (wav, mp3, etc...)
- common text/office formats (txt, html, word, excel, access, powerpoint, etc...)
Detecting file format?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Sounds more like the UNIX "file" command to me
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
anthony wrote: Sounds more like the UNIX "file" command to me
Well, I know about the "file" command, but would be needed a platform independent solution, as I develop my website under Windows. The "file" command uses a magic file, where the file footprints are listed. This could be also used by ImageMagick, too.
ImageMagick is platform independent, and such feature would make image detection much easier. And if images are detected, why not detect other file formats, too, so I can tell the visitor, what is wrong with his uploaded file?
I have a website, where users are uploading images. Sometimes they are also uploading files, which are not images at all or they are not supported by ImageMagick. This is why I would welcome a feature, which detects the format of the file. This feature should be also implemented into Perl API, because I use Perl language.
Developers?
Would you consider implementing such feature?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Unix uses such a file too, with the linux version much more advanced in entries.
However this "/etc/magic" is commonly published, so I am supprised a windows version whcih can use the UNIX 'magic' is not generally available.
For fast file type determination it is a lot faster than IM, as Im is restricted to just formats it knows about and often needs to read in to identify. Mind you for images IM identify can get you a lot more info, like Exif Metadata, but of course the price is speed.
Your choice.
However this "/etc/magic" is commonly published, so I am supprised a windows version whcih can use the UNIX 'magic' is not generally available.
For fast file type determination it is a lot faster than IM, as Im is restricted to just formats it knows about and often needs to read in to identify. Mind you for images IM identify can get you a lot more info, like Exif Metadata, but of course the price is speed.
Your choice.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
anthony wrote: For fast file type determination it is a lot faster than IM, as Im is restricted to just formats it knows about and often needs to read in to identify. Mind you for images IM identify can get you a lot more info, like Exif Metadata, but of course the price is speed.
Not faster, as Perl needs to use `backtick` operator to spawn perl interpreter, start the external command "file", then get its output. That's why using the ImageMagick Perl API is faster than using the backtick Perl operator.
IMHO, would be logical feature, to add a command which just quickly identify file type, using a short magic string.
Also note, ImageMagick has also the word magic in his name so this also adds a point to implement this feature
The Wizards Toolkit has a mime-detection method but ImageMagick does not. See http://www.wizards-toolkit.org/
magick wrote: The Wizards Toolkit has a mime-detection method but ImageMagick does not. See http://www.wizards-toolkit.org/
Yeah, thanks!
However it seems the Wizard's Toolkit doesn't have a Perl interface.