Code Monkey home page Code Monkey logo

gdimage's Introduction

Latest Stable Version Build Status StyleCI SensioLabsInsight License

GDImage

Easy to use image manipulation tool based on PHP-GD extension.

Key features

  • Easy to use.
  • JPEG, PNG, GIF, WEBP support.
  • Method chaining.
  • JPEG autorotation (ext-exif required) based on EXIF header
  • Easy to resize, crop, rotate, add text, flip, merge, set opactity

Requirements

How to install

composer require delfimov/gdimage

or add this line to your composer.json file:

"delfimov/gdimage": "~1.0"

Alternatively, copy the contents of the gdimage folder into one of your project's directories and require 'src/GDImage.php';.

A Simple Example

// initialize GDImage
$image = new GDImage('path/to/image.jpg');
 
// set fill color for empty image areas
$image->setFillColor([255, 0, 0]);

// Resize image. By default images are resized proportional and are not cropped,  
// with empty areas filled with color specified in setFillColor() method
$image->resize(1280, 720);

/* Add text to image 
The first parameter is text to add, 
the second parameter is optional, by default equals to: 
[
    'size' => 20,
    'angle' => 0,
    'x' => 0,
    'y' => 0,
    'color' => [0, 0, 0],
    'font' => '/../fonts/Roboto-Medium.ttf'
] 
*/
$image->addText(
    'Sample text to add',
    [
        'font' => __DIR__ . '/../fonts/Roboto-Medium.ttf',
        'size' => 18,
        'x' => 150,
        'y' => 100,
        'color' => [255, 0, 0]
    ]
);

// Save image
$image->save('path/to/newimage.jpg');

TODO

  • Examples
  • Readme
  • More unit tests
  • Animated gifs support

gdimage's People

Contributors

delfimov avatar ge1i0n avatar gdevilbat avatar

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.