elcuro/image2 问题修复 & 功能扩展

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

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

elcuro/image2

Composer 安装命令:

composer require elcuro/image2

包简介

README 文档

README

#Croogo Image2 plugin for Croogo 1.4+

This helper is modification of original Image helper boundled with Croogo. This version support method chaining and watermark image

Requirements

  • gdlib2

Installation

  • download and copy this plugin to app/Plugin/Image2
  • activate plugin in administration Extesions -> Plugins
  • create folder for resized images, default is app/webroot/uploads/resized. You can change it in plugin bootstrap.php
  • folder must have write permission

Example usage

Resize

Classic "hard" resize

   $this->Image2->source('img/screenshot.png')
          ->resizeit(50, 50, false)
          ->imagePath();  // return /uploads/resized/0_0_50_50_resize_screenshot.png

Ratio resize

   $this->Image2->source('img/screenshot.png')
          ->resizeit(50, 50, true)
          ->imagePath();  // return /uploads/resized/0_0_50_38_resize_screenshot.png

Crop

Crop direct from original image

   $this->Image2->source('img/screenshot.png')
          ->crop(200, 100, false)
          ->imagePath(); // return /uploads/resized/150_200_200_200_crop_screenshot.png

Resize image to longer side and then crop

   $this->Image2->source('img/screenshot.png')
          ->crop(200, 100)
          ->imagePath(); // return /uploads/resized/0_38_200_200_crop_screenshot.png

Watermark

Watermark image in PNG format, support for alpha channel.

   $this-Image2->watermark($watermark_image, $position, $watermark_absolute_path)
  • $watermark_image = path to watermark image

  • $position = position of watermark

  • $watermark_absolute_path = true if $watermark_image is absolute path

    $this->Image2->source('img/screenshot.png', 'center')
           ->resizeit(500, 500, false)
           ->watermark('img/croogo.png', 'center', false)
           ->imagePath() // return /uploads/resized/croogo_png_center_0_0_500_500_resize_screenshot.png
    

Positions:

  • center - center of the image, long size 70% of original image long side
  • overlay - watermark image is resized to equal sizes as original
  • pattern - watermark is croped to equal sizes as original, assume big pattern watermark
  • left bottom - not implemented yet
  • right bottom - not implemented yet
  • left top - not implemented yet
  • right top - not implemented yet

Inline image

Base64 encoded inline image

   $this->Image2->source('img/screenshot.png')
          ->crop(200, 100, false)
          ->inlineImage();  // return 'data:image/png;base64,i3fs.....'

Backward compatibility

"resize" method from previous version is supported

   $this->Image2->resize($path, $width, $height, $method = 'resizeRatio', $htmlAttributes = array(), $return = false, $server_path = false);

elcuro/image2 适用场景与选型建议

elcuro/image2 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 141 次下载、GitHub Stars 达 4, 最近一次更新时间为 2014 年 02 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 3
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2014-02-26