roelvanduijnhoven/reverse-image-cover
最新稳定版本:0.3.1
Composer 安装命令:
composer require roelvanduijnhoven/reverse-image-cover
包简介
Compute visible part of source image when covered in viewport
README 文档
README
Small library that can compute the part of the source image that is shown when it is being projected onto an element as background.
Can be used for example to reduce bandwidth by preprocessing the image so that only the crop is returned. The end result will be identical to the viewer.
Currently only supports backgrounds that cover the image and use percentages to position the image.
Usage
$viewport = new BackgroundCoverViewport( $viewportWidth, $viewportHeigt, $backgroundPositionX, $backgroundPositionY ); $crop = $viewport->computeUsedCrop( $imageWidth, $imageHeight ); echo "Visible part of image starts at({$crop[0]}, {$crop[1]}) "; echo "and has a dimension of {$crop[2]} x {$crop[3]}";
Tests
Tests can be ran by:
composer installvendor/bin/phpunit
The test suite can be visualized as follows:
- Run server
php -S localhost:8080 - Visit http://localhost:8080/tests/demo.php`
统计信息
- 总下载量: 1.19k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-08-11