MIME-Detect reviews

RSS | Module Info

MIME-Detect (0.08)

MIME::Detect offers two ways to get the MIME type, "mime_types", which gets the mime type of a file by reading the file itself, and "mime_types_from_name", which looks at the extension part of the file name, like ".txt" or ".png". Both of these functions return a list of mime types in case more than one pattern matches.

MIME::Detect uses a very large XML file from freedesktop.org for the matching patterns.

In my tests, MIME::Detect performed fairly well, although the file-inspecting "mime_types" method couldn't detect some formats, including executable files, files containing old encodings, and the old Microsoft BMP image format.

MIME::Detect is by far the slowest of all the modules I tried. Loading and using this single module takes more time than loading and checking the types of the files with all the other modules, "File::MMagic", "File::MMagic::XS", "Media::Type::Simple", "MIME::Types", "File::LibMagic", and "File::MimeInfo", combined.

The time of my test with with all of the above modules except MIME::Detect:

real 0m0.495s
user 0m0.440s
sys 0m0.056s

The time of my test including MIME::Detect:

real 0m1.918s
user 0m1.768s
sys 0m0.150s

It's probably because the module parses a two megabyte XML file each time it is started.

The list of all the other modules for detecting mime types in the module's SEE ALSO is useful.

For a full comparison including the testing program and results on various files, see :