PHPackages                             davidpersson/mm - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. davidpersson/mm

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

davidpersson/mm
===============

The PHP media library: media processing and MIME-Type/extension guessing.

v2.2.1(8y ago)2911.8k↓33.3%5[1 PRs](https://github.com/davidpersson/mm/pulls)2MITPHPPHP &gt;=5.5.0

Since Jun 5Pushed 4y ago3 watchersCompare

[ Source](https://github.com/davidpersson/mm)[ Packagist](https://packagist.org/packages/davidpersson/mm)[ RSS](/packages/davidpersson-mm/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (20)Used By (2)

```

xx xx  xx xx
x x x  x x x
x   x  x   x
-- The PHP media library.

Synopsis
--------
Making media processing portable isn't easy. Retrieving meta data from
media through one of the thousand extensions is by times overwhelming.
Dealing with MIME-types is most often limited to magic lookup.

This library is concerned with three aspects of media and organized
accordingly:

- Processing of media
- Retrieving media metadata
- Determining a file's MIME-type

The set of \mm\Media\* classes provide abstractions from underlying
extensions or libraries and most common methods for operations like
resizing and conversion (even between i.e. PDFs, movies and images).

The \mm\Mime\Type class helps with determining the MIME-type or correct
extension of a file or stream. It comes with adapters for the fileinfo
extension, glob and magic databases from the freedesktop project, as well
as modmime style databases.

The files required to make MIME detection work autonomously (i.e. without
the fileinfo extension installed) are shipped with the library. You'll
find those files in the data directory. Please note that the MIME magic
implementation in pure PHP will always be a lot slower than the PHP
extensions in C and currently has to be considered experimental.

Features
--------
The most significant features of this library are:

- Full suit of unit and integration tests
- Battle tested and used in production since over 6 years
- PSR-0 and PSR-4 compatiblity
- Fast Freedesktop glob file parser implemented in pure PHP
- FFmpeg and SoX adapters for video and audio conversion

Copyright & License
-------------------
MM, the PHP media library is Copyright (c) 2007 David Persson if
not otherwise stated. The code is distributed under the terms of the MIT
License. For the full license text see the LICENSE file.

Requirements
------------
The library is known to run fine under linux and darwin. Depending on
the adapters you are using you may need (this is a selection):

- ext/fileinfo
- ext/gd
- ghostscript
- ImageMagick
- ext/imagick >= 3.0.0
- FFmpeg >= 0.10.0, < 0.11.0
- SoX

Installation
------------
The preferred installation method is via composer. You can add the library
as a dependency via:

$ composer require davidpersson/mm

To bootstrap and pre-configure the library load the bootstrap file:

require /path/to/mm/bootstrap.php

Quickstart: MIME-type Detection
-------------------------------
Before we can use any of the classes we must configure them. The following
is just a minimal example. Have a look at the included `bootstrap.php` for
more information what's possible.

More documentation for MIME-type detection is available in the `docs`
subdirectory.

Guess the MIME type of the file.

Guess the extension (suffix) for an existing file or a MIME type.

Determine the common lowercase media name, with and without hints from a
magic lookup.

Quickstart: Media Processing
----------------------------
First we configure the class.

A common task is to convert an image into another format, apply some
compression while ensuring it has the sRGB profile embbeded. We'll utilize
the factory method here which handles MIME-type detection of the source
file for us and returns an appropriate \mm\Media\Process\* class for us.

Using the `Ffmpeg` adapter we can transcode videos programmatically. Using
the `passthru` method we can access the adapter more or less directly.

Quickstart: Media Information
-----------------------------
First we configure the class.

Getting information from an image. Information is assembled by all
configured adapters for the type.

Running the Tests
-----------------
This library is continously integrated. Please check the following URL
for information on the status of the latest builds:

http://travis-ci.org/#!/davidpersson/mm

Tests for this library are PHPUnit based. To run the tests you'll need
to have PHPUnit installed[1]. Following command will run all the tests.

$ phpunit

[1] http://www.phpunit.de/manual/current/en/installation.html

Documentation
-------------
Documentation is available in the `docs` directory.

```

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 99.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~71 days

Recently: every ~27 days

Total

19

Last Release

3087d ago

Major Versions

v1.2.0 → v2.0.0-alpha2014-06-15

### Community

Maintainers

![](https://www.gravatar.com/avatar/a358e1a5ab7f7c81ecaae07acd830aa4a36726ab4da46a11df754a6e5b3a4cda?d=identicon)[mariuswilms](/maintainers/mariuswilms)

---

Top Contributors

[![mariuswilms](https://avatars.githubusercontent.com/u/29702?v=4)](https://github.com/mariuswilms "mariuswilms (303 commits)")[![whoem](https://avatars.githubusercontent.com/u/6699384?v=4)](https://github.com/whoem "whoem (1 commits)")

---

Tags

pdfimagickmimeffmpegglobmediafileinfosoxfreedesktopxdg

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/davidpersson-mm/health.svg)

```
[![Health](https://phpackages.com/badges/davidpersson-mm/health.svg)](https://phpackages.com/packages/davidpersson-mm)
```

###  Alternatives

[symfony/mime

Allows manipulating MIME messages

2.8k668.8M911](/packages/symfony-mime)[zbateson/mail-mime-parser

MIME email message parser

54149.2M79](/packages/zbateson-mail-mime-parser)[php-mime-mail-parser/php-mime-mail-parser

A fully tested email parser for PHP 8.0+ (mailparse extension wrapper).

9979.6M27](/packages/php-mime-mail-parser-php-mime-mail-parser)[nette/mail

📧 Nette Mail: A handy library for creating and sending emails in PHP.

5389.8M246](/packages/nette-mail)[zbateson/stream-decorators

PHP psr7 stream decorators for mime message part streams

4748.6M6](/packages/zbateson-stream-decorators)[silverstripe/mimevalidator

Checks uploaded file content roughly matches a known MIME type for the file extension.

102.0M9](/packages/silverstripe-mimevalidator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
