renus/media
最新稳定版本:0.5
Composer 安装命令:
composer require renus/media
包简介
Symfony Bundle to handle image and video
README 文档
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);
统计信息
- 总下载量: 170
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-04-11