renus / media
Symfony Bundle to handle image and video
Installs: 169
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
This package is not auto-updated.
Last update: 2025-01-04 19:12:13 UTC
README
RenusMediaBundle is a collection of code within a Symfony 2 Bundle to handle image and video, you can create an image or animated gif from a video source or resize, obfuscate and crop an image in Symfony 2.
To use RenusMediaBundle in your project add it via composer
Installation
prerequisites
To use RenusMediaBundle you must install and know the path of 'ffmpeg' binary (on Debian):
apt-get install ffmpeg php5-ffmpeg php5-imagick
configuration
if you use a non standard Debian installation, you must specify the path to ffmpeg in your parameters file :
parameters:
binary: '/usr/bin/ffmpeg'
installation
- Add this bundle to your project in composer.json:
{ "require": { "renus/media": "0.*", } }
- Install with composer
composer.phar require renus/media dev-master
- Register the bundle
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new \Renus\MediaBundle\RenusMediaBundle(), ); // ... }
Usage
In Symfony 2 controller, you can use it like a service
extract an image from video
extract the image at 55 seconds
<?php $this->container->get('renus.video')->getPicsFromVideo( '/path/to/video/vid1.m4v', 55, '/path/to/generate/image/vid1.jpg' );
create an animated gif from video
get an image every 10 seconds to build the animated gif
<?php $this->container->get('renus.video')->generateAnimatedGifFromVideo( '/path/to/video/vid1.m4v', 10, '/path/to/generate/image/vid1.gif' );
resize an image
Choose the destination path and the max size (300px here)
<?php $this->container->get('renus.image') ->init('/path/to/image.jpg') ->createThumb('/path/to/resize-thumb.jpg', 300);
crop an image
Choose the destination path , define the start X point and the start Y point, the width and the height of the selection.
<?php $this->container->get('renus.image') ->init('/path/to/image.jpg') ->crop('/path/to/crop-thumb.jpg', 100, 25, 300, 250);