mesavolt / imaging-bundle
用于在PHP中简化图像处理的Symfony组件
v0.3.0
2019-11-27 17:09 UTC
Requires
- php: >=7.1
- ext-exif: *
- ext-fileinfo: *
- ext-gd: *
- rosell-dk/webp-convert: ^2.3
- symfony/config: ^3.3||^4.1
- symfony/dependency-injection: ^3.3||^4.1
- symfony/http-kernel: ^3.3||^4.1
Requires (Dev)
- php-coveralls/php-coveralls: ^2.1
- phpunit/phpunit: ^7.2
This package is auto-updated.
Last update: 2024-09-10 06:36:54 UTC
README
安装
使用 composer
composer require mesavolt/imaging-bundle
不使用Symfony Flex的应用程序
如果您不使用Symfony Flex,需要手动启用此组件。为此,请将其添加到项目中的 app/AppKernel.php
文件中已注册的组件列表中
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new Mesavolt\ImagingBundle\ImagingBundle(), ); // ... } // ... }
配置
以下选项可用于自定义组件图像服务的行为
使用方法
将 Mesavolt\ImagingBundle\ImagingService
服务注入到您的服务和控制器中(或从容器中获取 mesavolt.imaging
服务)
<?php namespace App; use Mesavolt\ImagingBundle\Service\ImagingService; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; class HomeController extends AbstractController { public function index(ImagingService $imagingService) { $relative = '/public/thumbnails/thumbnail.jpeg'; $path = $this->getParameter('kernel.project_dir').$relative; $imagingService->shrink('/tmp/image.jpg', $path); return $this->render('home/index.html.twig', [ 'shrunk' => $relative ]); } }