0.2.0 2017-06-26 16:41 UTC

This package is auto-updated.

Last update: 2020-10-21 22:36:38 UTC


README

logo

Crop

Latest Stable Version Minimum PHP Version License PayPal donation Buy me a coffee Become a Patron

(This product is available under a free and permissive license, but needs financial support to sustain its continued improvements. In addition to maintenance and stability there are many desirable features yet to be added.)

This component will resize images following configuration rules. allows only defined format

Installation

composer require femtopixel/crop

Usage

<?php
$formats = array(
    'mini' => array(
        'width' => 100,
        'height' => 100,
        'full' => 'cropped',
    ),
);
$image = new \FemtoPixel\Crop\Crop('/path/to/file.png', 'mini');
$image->setFormatsFromArray($formats)->render();

You can define as many format that you want!

  • First parameter is path to your file to display
  • Second (optional) is the format you want to display in (default : 'original' (no modification))
  • Third (optional) is path to default image displayed if path in first parameter doesn't exist. This file will be displayed in requested format. (default : 'src/missing.png')

Configuration

Each format given in method setFormatsFromArray must define width, height and optional full index.

full can be configured to 4 values depending on attended rendering :

  • none : No cropping, no resize. Will render image with original file dimensions.
  • cropped : Crop the rendered image to be exactly dimensions defined in configuration.
  • height : Resize the image without distortion to have height to value defined in configuration.
  • width : Resize the image without distortion to have width to value defined in configuration.