File::Type::WebImages(3pm)

File::Type::WebImages3pm

Determine web image file types using magic

Usage

    use File::Type::WebImages 'mime_type';
    
    my $type_1 = mime_type($file);
    my $type_2 = mime_type($data);

Overview

"mime_type()" can use either a filename, or file contents, to determine the type of a file. The process involves looking the data at the beginning of the file, sometimes called "magic numbers".

The big trade off

For minimum memory consumption, only the following common web image file types are supported:

BMP, GIF, JPEG and PNG. ( image/bmp, image/gif, image/jpeg and image/png ).

Unlike with File::Type and File::MMagic, 'undef', not "application/octet-stream" will be returned for unknown formats.

Unlike File::Type, we return "image/png" for PNGs, not "image/x-png";

If you want more mime types detected use File::Type or some other module.

Todo

It would be even better to have a pluggable system that would allow you to plug-in different sets of MIME-types you care about.

Acknowledgments

File::Type::WebImages is built from a mime-magic file from cleancode.org. The original can be found at <http://cleancode.org/cgi-bin/viewcvs.cgi/email/mime-magic.mime?rev=1.1.1.1>.

Releases

7 releases since Debian 7 (Wheezy); the text changed 3 times.

  1. 7–8
  2. 9–10
  3. 11
  4. 12–13

Authors

Paul Mison <[email protected]> - wrote original File::Type Mark Stosberg <[email protected]> - hacked up this.

License

Licensed under the same terms as Perl itself.

From libfile-type-webimages-perl 1.01-4 in Debian 13 (Trixie). Parsed by carta from the page's man source.