承接 stratease/imagi-fly 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

stratease/imagi-fly

最新稳定版本:v0.2.7

Composer 安装命令:

composer require stratease/imagi-fly

包简介

PHP Image Filter library

README 文档

README

PHP Library to process images through any number of filter effects, based on a single source image. Web API Inspired by https://github.com/imsky/holder

Makes use of the Intervention Image library for image processing.

Example

<img src="/image-builder/path/to/my/file.png/225x225/overlay:2/" >

The first portion of the path is the image builder path prepend /image-builder/ which denotes the remaining portion of the path is to be handled by the parser.

Next is the path to the image /path/to/my/file.png. These should typically be a transparent images to allow certain filters to operate appropriately.

And finally there are 2 filters being applied to this image. A special resizing filter /225x225/ which denotes a 225 pixel width and 225 pixel height, respectively. Followed by /overlay:2/ an overlay filter, specifying 2 duplicates of the original image to be positioned next to each other.

If we had used an original image of ...

original file

... after utilizing ImagiFly's filter path, the resulting image would be

parsed file

Setup

Check out our demo to see an example setup.

It's important to note that on the backend we have a server directive to route to our PHP image builder file based on the /image-builder/... path.

This will provide a level of overhead for each requested image, and is not recommended for very high traffic sites. We do provide a level of caching to avoid redundant image processing.

Our .htaccess for apache

RewriteEngine On
RewriteRule ^image-builder/.*$ image-builder.php [NC,L]

This redirects to our backend script that handles the route parsing and image manipulation.

use stratease\ImagiFly\Builder;
use stratease\ImagiFly\RequestParser;
require_once("../vendor/autoload.php");
require_once("PinkFilter.php");


$builder = new Builder(['baseDirectory' => __DIR__.'/images/', // Path where we store base images. Can be in web directory or any location
    'cache' => false, // Lets disable the cache so we can see our PinkFilter adjustments per request.
    // Our request parser. You can provide your own by implementing the RequestParserInterface
    'requestParser' => new RequestParser(['requestPath' => $_SERVER['REQUEST_URI'],
                                            'pathPrepend' => 'image-builder'])]);

// this is how we register a custom filter, in our case an awesome PinkFilter
$builder->addFilterExtension(PinkFilter::getFilterMask(), new PinkFilter());

$builder->output(); // This will compile and output the image.

// Try this path.. /image-builder/chipmunks-are-awesome.png/225x225/overlay:2/pink:unicorn/
// it'll blow your mind!

This implementation also has an example of how to setup a custom filter. Refer to the FilterInterface for further documentation.

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 5
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-08-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固