wapmorgan/imagery 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

wapmorgan/imagery

Composer 安装命令:

composer require wapmorgan/imagery

包简介

Simple image editor for resizing, cropping, making collages and other elementary actions with images.

关键字:

README 文档

README

Imagery supports:

  • resizing
  • cropping
  • flipping and rotating
  • making collages
  • applying filters and effects

Composer package Latest Stable Version Total Downloads License

  1. Installation
  2. API

Installation

  • Composer package:
  composer require wapmorgan/imagery

API

Imagery

use Imagery\Imagery;

Opening

Create new Imagery object:

  • $image = Imagery::open($filename); - from a file.
  • $image = Imagery::create($width, $height); - new image
  • $image = new Imagery(imagecreatefrombmp('image.bmp')); - from a resource

Saving

  • public function save($filename, $quality = 75, $format = null) - saves image to disk. Quality is an integer value between 0 (worst) and 100 (best). Default is 75. Quality is applicable only to JPEG, PNG, WEBP. If $format can not be determined by filename extension, specifcy it explicitly.

Formats supports:

Operation Formats
Opening jpeg, png, gif, bmp, wbmp, xbm, xpm, webp (php >= 7.1.0)
Saving jpeg, png, gif, bmp, wbmp, xbm, webp (php >= 7.1.0)

Properties

  • $image->width - width of image
  • $image->height - height of image
  • $image->resource - original gd-resource of image (you can use it with gd-functions)

Resize && Zoom

  • public function resize(int $width, int $height) - resizes an image to $width X $height
  • public function zoomWidthTo(int $size) - changes proportionally image width to $size
  • public function zoomHeightTo(int $size) - changes proportionally image height to $size
  • public function zoomMaxSide(int $size) - zoomes proportionally larger side to $size, if needed

Crop

  • public function crop($x, $y, $x2, $y2) - cuts a rectangular piece of image
  • public function decreaseSide($side, int $size) - deletes a piece of image from specific side. For example, if $side=top and $size=100, 100px from top will be deleted.

Rotation && Mirroring

  • public function rotate($angle, $bgColor = 0) - rotates an image. True equals 90°, False equals -90°.
  • public function flip($horizontally = true) - flips an image horizontally or vertically.

Collage

  • public function appendImageTo($side, Imagery $appendix, int $modifiers) - appends an image ($appendix) to current image at $side (top|bottom|left|right). Modifiers:

    • Imagery::ZOOM_IF_LARGER - appendix' height will be zoomed (not resized) if it's larger than current image's one (when appending to left or right side); appendix' width will be zoomed (not resized) if it's larger than current image's one (when appending to top or bottom side);
  • public function placeImageAt($x, $y, Imagery $image) - places an image atop current image at $x X $y.

  • public function placeImageAtCenter(Imagery $image) - places an image in the center of current image.

Effects

  • public function filter($filter) - applies grayscale or negate filter. Pass Imagery::FILTER_NEGATE or Imagery::FILTER_GRAYSCALE as $filter.

    Grayscale:

    Original -> Grayscale

    Negate:

    Original -> Negate

  • public function changeContrast($newValue) - changes contrast of image. New values can be in range from 100 (max contrast) to -100 (min contrast), 0 means no change.

    Original -> Negate

  • public function changeBrightness($newValue) - changes brightness of image. New values can be in range from 255 (max brightness) to -255 (min brightness), 0 means no change.

    Original -> Negate

  • public function colorize($red, $green, $blue, $alpha = 127) - changes colors of image. Colors ($red, $green, $blue) can be in range from 255 to -255. $alpha from 127 to 0.

    Original -> Negate

  • public function blur($method) - blurs an image. Method can be Imagery::GAUSSIAN_BLUR or Imagery::SELECTIVE_BLUR.

    Original -> Negate

  • public function smooth($level) - smooths an image. Level of smoothness can be in range from 0 to 8. 8 is un-smooth.

    Original -> Negate

  • public function pixelate($blockSize = 5, $useModernEffect = true) - pixelates an image. $blockSize is size of pixel block.

    Original -> Negate

Tools

There's a tools class: Imagery/Tools.

  • static public function pHash(Imagery $image, $sizes = array(8, 8))

    Calculates Perceptual hash of image.

wapmorgan/imagery 适用场景与选型建议

wapmorgan/imagery 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 174 次下载、GitHub Stars 达 25, 最近一次更新时间为 2017 年 01 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「images」 「phash」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 wapmorgan/imagery 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 wapmorgan/imagery 我们能提供哪些服务?
定制开发 / 二次开发

基于 wapmorgan/imagery 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 174
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 25
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 25
  • Watchers: 8
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-01-11