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.
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).
updatemi/imagex 适用场景与选型建议
updatemi/imagex 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.62k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 02 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 updatemi/imagex 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 updatemi/imagex 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2.62k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-02-27
