Giter Site home page Giter Site logo

imagemerge's Introduction

Image Merge

A simple PHP libraty to manipulate images, it support GIF, PNG and JPG

Latest Stable Version Total Downloads Latest Unstable Version License Build Status Scrutinizer Code Quality

Requirement

PHP >= 5.6 with GD support *For some additional features (for example image distortion) ImageMagick binaries are required.

Getting Started

Install library with composer

composer require jackal/image-merge

Usage

Minimal example


$imageMerge = new ImageMerge();
$imageBuilder = $imageMerge->getBuilder('/path/to/my/file.png'); #or URL, or resource, or binary content

$imageBuilder->resize(620,350)
$imageBuilder->rotate(90);

Get the image content directly to the output

[...]
echo $imageBuilder->getImage()->toPNG()->getContent();  

Save image to path

[...]
$builder->getImage()->toPNG('/path/to/the/image.png');

Get image Response object (Compatible with Symgony projects)

[...]
return $imageBuilder->getImage()->toPNG()

resize

At least one parameter is required In case just one parameter is passed, it will resize maintaining the aspect ratio of the image

$imageBuilder->resize(620,null);
#or
$imageBuilder->resize(null,200);

If both parameters are passed, it could stretch the image

$imageBuilder->resize(400,200);

thumbnail

Similar to Resize but in case the aspect ratio is not respected, it will crop the image (using cropCenter)

$imageBuilder->thumbnail(400,400);

rotate

Rotate the image (counterclockwise)

$imageBuilder->rotate(180);

*In case of particular angle (30, 45, etc..) it will create blank area to fill the empty spaces

grayscale

Add a graysclae filter to the image

$imageBuilder->grayScale();

brightness

Adjusts the brightness of the image

$imageBuilder->brightness(10);

blur

Adds blur effect on the image

$imageBuilder->blur(20);

pixelate

Adds "Pixel" effect on the image

$imageBuilder->pixelate(20);

crop and cropCenter

Crop Crop the image according to the x and y coords and the output dimention passed

$point_x = 10,
$point_y = 15;
$width = 50,
$height = 50;
$imageBuilder->crop($point_x,$point_y,$width,$height);

Crop at the center of the image according to the width and height of the output image

$width = 50,
$height = 50;
$imageBuilder->cropCenter($point_x,$point_y,$width,$height);

border

It adds border to the image (fill inside the rect)

$stroke = 20;
$colorHex = '3399ff';
$builder->border($stroke,$colorHex);

Experimental features that will likely change in the future

addText

It adds text inside the image

$text = new Jackal\ImageMerge\Model\Text\Text('this is the text', Font::arial(), 12, new Color('ABCDEF'));
$builder->addText($text, 10, 20);

addSquare

It adds a square (color-filled) on the image

$builder->addSquare(10, 10, 20, 20, 'ABCDEF');

===========================================================================

Author

  • Luca Giacalone (AKA JackalOne)

License

This project is licensed under the MIT License

imagemerge's People

Stargazers

Luca Giacalone avatar Shawn Duncan avatar Lorenzo avatar

Watchers

James Cloos avatar Lorenzo avatar  avatar Luca Giacalone avatar

Forkers

antoinelemaire

imagemerge's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.