mesavolt/imaging-bundle

用于在PHP中简化图像处理的Symfony组件

安装: 65

依赖者: 0

建议者: 0

安全性: 0

星标: 1

关注者: 2

分支: 0

开放问题: 2

类型:symfony-bundle

v0.3.0 2019-11-27 17:09 UTC

README

Build Status Coverage Status

安装

使用 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
        ]);
    }
}