2017 © Pedro Peláez
 

library reverse-image-cover

Compute visible part of source image when covered in viewport

image

roelvanduijnhoven/reverse-image-cover

Compute visible part of source image when covered in viewport

  • Tuesday, July 18, 2017
  • by roelvanduijnhoven
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,169 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 1 % Grown

The README.md

Reverse Image Cover

Small library that can compute the part of the source image that is shown when it is being projected onto an element as background., (*1)

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., (*2)

Currently only supports backgrounds that cover the image and use percentages to position the image., (*3)

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:, (*4)

  1. composer install
  2. vendor/bin/phpunit

The test suite can be visualized as follows:, (*5)

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

The Versions

18/07 2017

dev-master

9999999-dev

Compute visible part of source image when covered in viewport

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

18/07 2017

0.3

0.3.0.0

Compute visible part of source image when covered in viewport

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

14/08 2015

0.1.2

0.1.2.0

Compute visible part of source image when covered in viewport

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

12/08 2015

0.1.1

0.1.1.0

Compute visible part of source image when covered in viewport

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires