mafa/

imageaspect

ImageAspect - 简单的图像宽高比裁剪协调生成器。

0.1.2 2020-12-28 05:34 UTC

This package is auto-updated.

Last update: 2024-09-28 13:56:31 UTC


README

ImageAspect - 简单的图像宽高比裁剪协调生成器。

安装

Composer

composer require mafa/imageaspect

快速示例

$imageAspect = new \MAfa\ImageAspect\ImageAspect(800, 440);
$coordinates = $imageAspect->aspect(2, 1)->generateCoordinates();

// Response is a ImageAspectModel object
MAfa\ImageAspect\ImageAspectModel {
  -width: 800
  -height: 400
  -x: 0
  -y: 0
}

// x is integer to crop from left of image
$coordinates->getX();

// y is integer to crop from top of image
$coordinates->getY();

// width is integer to crop to right of image and width of final width in expected aspect ratio
$coordinates->getWidth();

// height is integer to crop to bottom of image and width of final height in expected aspect ratio
$coordinates->getHeight();

ImageAspectModel 对象