src/Manipulators/Size.php
public function resolveCropOffset(Image $image, $width, $height)
    {
        list($offset_percentage_x, $offset_percentage_y) = $this->getCrop();

        $offset_x = (int) (($image->width() * $offset_percentage_x / 100) - ($width / 2));
        $offset_y = (int) (($image->height() * $offset_percentage_y / 100) - ($height / 2));

        $max_offset_x = $image->width() - $width;
        $max_offset_y = $image->height() - $height;

        if ($offset_x < 0) {
            $offset_x = 0;
        }

        if ($offset_y < 0) {
            $offset_y = 0;
        }

        if ($offset_x > $max_offset_x) {
            $offset_x = $max_offset_x;
        }

        if ($offset_y > $max_offset_y) {
            $offset_y = $max_offset_y;
        }

        return [$offset_x, $offset_y];
    }
public function resolveCropOffset(Image $image, $width, $height)
    {
        list($offset_percentage_x, $offset_percentage_y) = $this->getCrop();

        $offset_x = (int) (($image->width() * $offset_percentage_x / 100) - ($width / 2));
        $offset_y = (int) (($image->height() * $offset_percentage_y / 100) - ($height / 2));

        $max_offset_x = $image->width() - $width;
        $max_offset_y = $image->height() - $height;

        if ($offset_x < 0) {
            $offset_x = 0;
        }

        if ($offset_y < 0) {
            $offset_y = 0;
        }

        if ($offset_x > $max_offset_x) {
            $offset_x = $max_offset_x;
        }

        if ($offset_y > $max_offset_y) {
            $offset_y = $max_offset_y;
        }

        return [$offset_x, $offset_y];
    }
public function resolveCropOffset ( Image $ image , $ width , $ height ) { list ( $ offset_percentage_x , $ offset_percentage_y ) = $ this -> getCrop ( ) ; $ offset_x = ( int ) ( ( $ image -> width ( ) * $ offset_percentage_x / 100 ) - ( $ width / 2 ) ) ; $ offset_y = ( int ) ( ( $ image -> height ( ) * $ offset_percentage_y / 100 ) - ( $ height / 2 ) ) ; $ max_offset_x = $ image -> width ( ) - $ width ; $ max_offset_y = $ image -> height ( ) - $ height ; if ( $ offset_x < 0 ) { $ offset_x = 0 ; } if ( $ offset_y < 0 ) { $ offset_y = 0 ; } if ( $ offset_x > $ max_offset_x ) { $ offset_x = $ max_offset_x ; } if ( $ offset_y > $ max_offset_y ) { $ offset_y = $ max_offset_y ; } return [ $ offset_x , $ offset_y ] ; }
Resolve the crop offset.
@param  Image   $image  The source image.
@param  integer $width  The width.
@param  integer $height The height.
@return array   The crop offset.
Resolve the crop offset .