1. Go to this page and download the library: Download davidpersson/mm library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use mm\Media\Process;
Process::config([
'image' => 'Imagick',
'video' => 'Ffmpeg'
]);
use mm\Media\Process;
$media = Process::factory(['source' => '/path/to/cat.png']);
// $media is now an instance of `\mm\Media\Process\Image`.
// Fit image into a square of 500 by 500px. More resizing methods like crop
// and zoom are available, too.
$media->fit(500, 500);
// We use the official ICC sRGB profile that comes with this library.
$media->colorProfile(__DIR__ . '/data/sRGB_IEC61966-2-1_black_scaled.icc');
// Reduce color depth.
$media->colorDepth(8);
// All but the `convert` method operate on the loaded source. `convert`
// instead returns a new `Image` object which must be used from now on.
$media = $media->convert('image/jpeg');
// Now we store the converted image.
$media->store('/path/to/cat_square.jpg');
use mm\Media\Process;
$media = Process::factory(['source' => '/path/to/dog.mp4']);
// $media is now an instance of `\mm\Media\Process\Video`.
// Resizing is the same as with operating on images. Here
// we resize to 720p HD.
$media->fit(1280, 720);
// We want to transcode to WEBM here.
$media = $media->convert('video/webm');
// We can tune the output accessing certain parameters of FFmpeg direcly.
$media->passthru('codec:a', 'libvorbis');
$media->passthru('codec:v', 'libvpx');
$media->passthru('b:a', '192k'); // audio bitrate
$media->passthru('b:v', '1024k); // video bitrate
$media->passthru('quality', 'good);
// Finally start transcoding and store file.
$media->store('/path/to/dog_720p.webm');
use mm\Media\Info;
Info::config([
'image' => ['ImageBasic', 'Imagick']
]);
$media = Info::factory(['source' => '/path/to/cat.png']);
// $media is now an instance of `\mm\Media\Info\Image`.
// The following showcases some basic methods.
$width = $media->width();
$megapixel = $media->megapixel();
$knownRatio = $media->knownRatio(); // may return 'Φ:1' (Goldener Schnitt).
// Get all available information as an array from the media. This is also
// a good method to give you an overview which data is possibly available
// using certain adapter combinations.
$meta = $media->all();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.