roelvanduijnhoven/reverse-image-cover 问题修复 & 功能扩展

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

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

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:

  1. composer install
  2. vendor/bin/phpunit

The test suite can be visualized as follows:

  1. Run server php -S localhost:8080
  2. Visit http://localhost:8080/tests/demo.php`

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-08-11