updatemi/imagex 问题修复 & 功能扩展

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

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

updatemi/imagex

Composer 安装命令:

composer require updatemi/imagex

包简介

A simple image service which support cropping with a focus point

README 文档

README

Requirements

  • PHP >= 5.5
  • PHP-Extension Imagick

Installation

  • Copy all included files to server destination of your choice
  • Create following folders and make sure that your web server has write permissions for these -- cache/source -- cache/thumbs
  • Setup following command as cron job to clean up local cache directories periodically: -- find ./cache -mtime +30 -type f -delete

Optional Apache Config for clean URLs

If you have mod_rewrite installed on your Apache server you can use following rewrite rule to enable clean URLs for the imagex service:

  RewriteRule (crop|resize)\/([0-9]*)\/([0-9]*)(\/([-+]?[0-1]+\.?[0-9]*)\/([-+]?[0-1]+\.?[0-9]*))?\/([A-Za-z0-9+/=]+)(:(nocache))?$ %{ENV:BASE}/imagex.php?mode=$1&width=$2&height=$3&x=$5&y=$6&url=$7&cache=$9 [NE,L]

After an apache restart you can also use imagex with URLs like the following:

http://my.domain.com/crop/400/280/0.18/0.25/http://upload.wikimedia.org/wikipedia/commons/e/e9/Official_portrait_of_Barack_Obama.jpg

Usage

http://my.domain.com/imagex.php?url=http://upload.wikimedia.org/wikipedia/commons/e/e9/Official_portrait_of_Barack_Obama.jpg&mode=crop&width=400&height=280&x=0.18&y=0.25

Parameters

The following 6 parameters are currently available:

url (required)

The url of the image you want to resize/crop/proxy. You can also base64-encode the url parameter if you like.

mode

Currently two modes are available: "resize" and "crop". Default is "resize".

width

Width of the resulting image. If no width is specified width will be scaled proportionally to the request height. If neither width nor height are specified the image will simply be proxied.

height

Height of the resulting image. If no height is specified width will be scaled proportionally to the request width. If neither width nor height are specified the image will simply be proxied.

x

X-coordinate of the focus point used for cropping the image. Value must be between -1 and 1. Default is 0 - the middle of the axis. See below for more information about the focus point functionality.

y

Y-coordinate of the focus point used for cropping the image. Value must be between -1 and 1. Default is 0 - the middle of the axis. See below for more information about the focus point functionality.

More details about the focus point

This is basically implemented the same way as in the [https://github.com/jonom/jquery-focuspoint](jquery-focuspoint plugin):

An image's focus point is made up of x (horizontal) and y (vertical) coordinates. The value of a coordinate can be a number with decimal points anywhere between -1 and +1, where 0 is the centre. X:-1 indicates the left edge of the image, x:1 the right edge. For the y axis, y:1 is the top edge and y:-1 is the bottom.

image

Confused? Don't worry, there's a handy script included to help you find the focus coordinates of an image with a single click. Check out the helper tool (vastly improved courtesy of @auginator).

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 4
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固