Content analysis for the purpose of determining Internet media types.
- PHP 5.3+
Through Composer as dflydev/canal.
<?php
// Instantiate the Analyzer
$analyzer = new Dflydev\Canal\Analyzer\Analyzer;
// Detect a media type from a filename (file does not need to exist)
$internetMediaType = $analyzer->detectFromFilename('/path/to/whatever.png');
// See the media type as a string
print $internetMediaType->asString()."\n\n";
// See the media type's type
print $internetMediaType->getType()."\n\n";
// See the media type's subtype
print $internetMediaType->getSubtype()."\n\n";
// image/png
//
// image
//
// png
MIT, see LICENSE.
This work was heavily influenced by Apache Tika and Ferret.