xymak / php-smartcrop-extension

smartcrop implementation in php extension

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

php-smartcrop-extension

smartcrop implementation in php-extension.

smartcrop finds optimal crops for images, based on Jonas Wagner's smartcrop.js.

Example

Installation

Make sure you have compiled PHP7 environment.

Additionally PHP GD extension is needed to be load into PHP.

This PHP extension can only work on Linux OS.

You can install it by running:

cd /path/to/php/extention/source/directory
https://github.com/xymak/php-smartcrop-extension.git
cd php-smartcrop-extension
phpize
./configure --prefix='/path/to/php/directory' --with-php-config='/path/to/php/config'
make && make install
echo "extension=smartcrop.so" >> /path/to/etc/php/php.d/smartcorp.ini

Example

<?php
//Convert to a image to gd resource
$im = imagecreatefromstring(file_get_contents('/path/to/a/image'));
//Target Size
$width = 400;
$height = 400;
//Call smartcrop function
$cim = smartcrop($im,$width,$height);

About

smartcrop implementation in php extension


Languages

Language:C 84.3%Language:M4 9.5%Language:PHP 4.6%Language:JavaScript 1.6%