Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/alexantr/image-resize

Image resizing library
https://github.com/alexantr/image-resize

crop gd image-processing images imagick php thumbnails

Last synced: 2 months ago
JSON representation

Image resizing library

Awesome Lists containing this project

README

        

# ImageResize

Image resizing library. Creates images on demand using GD.

## Install

Install through [Composer](http://getcomposer.org/):

```
composer require alexantr/image-resize
```

## Examples

See full list of examples in `example` folder.

Creating URLs:

```php
use Alexantr\ImageResize\Image;

$src1 = Image::init('uploads/pic.jpg')->crop(200, 200);
$src2 = Image::init('uploads/pic.jpg')->silhouette()->quality(95)->fit(200, 200);
$src3 = Image::init('uploads/pic.jpg')->fitWidth(200);
$src4 = Image::init('uploads/pic.jpg')->fitHeight(200);
$src5 = Image::init('/site/uploads/pic.jpg')->bgColor('6af')->fill(200, 200);
```

Can use class member access on instantiation in PHP 5.4 or higher:

```

```

## Creator example

Apache `.htacces` file:

```
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^resized/(.*)$ image.php?path=$1 [L]
```

`image.php` in web root folder:

```php
require '../vendor/autoload.php';

$webroot = __DIR__;
$path = isset($_GET['path']) ? $_GET['path'] : '';

Alexantr\ImageResize\Creator::create($webroot, $path);
```