bencagri / photon-bundle
1.0.0
2018-02-09 13:48 UTC
Requires
- bencagri/photon: ^1.0
This package is auto-updated.
Last update: 2024-09-28 23:45:45 UTC
README
Photon 是一个为 Jetpack 连接的 WordPress 网站提供图像加速和修改的服务。
要在 symfony 中使用,PhotonBundle 使用 Photon Wrapper
兼容 Symfony 3.x,4.x
安装
composer require bencagri/photon-bundle
然后在 app/AppKernel.php
中注册此包
<?php use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; class AppKernel extends Kernel { public function registerBundles() { $bundles = [ .... //Photon Bundle new \Bencagri\PhotonBundle\PhotonBundle(), ];
这样就完成了。
用法
在 Symfony 中有一个可以使用的服务。
在你的 controller
中;
use Photon\Wrapper\Effect\Filter; use Photon\Wrapper\Effect\Width; use Photon\Wrapper\Effects; ... public function indexAction(Request $request) { //get the service $generator = $this->get('bencagri.photon.service'); //register the effects that you want to use $effects = new Effects( new Width(700), new Filter('emboss') ); $imageUrl = 'https://images.com/my.jpg'; //generate the picture $generator->setImageUrl($imageUrl); $generator->setEffects($effects); $generator->generate(); }
查看 Photon Wrapper 可以使用的所有效果示例 examples.
许可
- Photon Bundle 是开源软件,许可协议为 MIT 协议。
- Photon Wrapper 是开源软件,许可协议为 MIT 协议。
- Photon 是开源软件,许可协议为 GNU 通用公共许可证。