PHP library to easily edit image with GD extension. Resize, crop, merge, draw, and many more options !

Overview

PHP Image Editor

PHP library to easily edit image with GD extension. Resize, crop, merge, draw, and many more options !

Supporting

Star this repository to support this project. You will contribute to increase the visibility of this library 🙂

Installation

Install this library easily with composer :

composer require dantsu/php-image-editor

How to use

Example 1

Create a empty image, draw on it and display it :

use \DantSu\PHPImageEditor\Image;

\header('Content-type: image/png');

$image = Image::newCanvas(500, 500)
    ->drawRectangle(0, 0, 500, 500, '#444')
    ->drawRectangle(0, 350, 500, 500, '#FF8800')
    ->writeText('I got the power !', __DIR__ . '/resources/font.ttf', 40, '#FFFFFF', Image::ALIGN_CENTER, 310)
    ->drawCircle(25, 100, 100, '#FF8800')
    ->drawCircle(25, 100, 95, '#000000FF')
    ->drawCircle(475, 100, 100, '#FF8800')
    ->drawCircle(475, 100, 95, '#000000FF');

for($i = 0; $i <= 360; $i+=30) {
    $image
        ->drawArrowWithAngle(250, 200, $i, 80, 2, '#FF8800')
        ->drawArrowWithAngle(250, 200, ($i + 15), 50, 2, '#FF8800');
}

$image
    ->crop(450, 300, Image::ALIGN_CENTER, Image::ALIGN_MIDDLE)
    ->displayPNG();

Sample 1

Example 2

Apply a watermark on a photo and save it :

use \DantSu\PHPImageEditor\Image;

Image::fromPath(__DIR__ . '/resources/photo.jpg')
    ->downscaleAndCrop(1920, 1080, Image::ALIGN_CENTER, Image::ALIGN_BOTTOM)
    ->pasteOn(
        Image::fromPath(__DIR__ . '/resources/watermark.png')->downscaleProportion(300, 300),
        Image::ALIGN_RIGHT,
        Image::ALIGN_TOP
    )
    ->saveJPG(__DIR__ . '/my-image.jpg', 70);

Sample 2

Documentation

See DantSu\PHPImageEditor\Image documentation class for more details.

Contributing

Please fork this repository and contribute back using pull requests.

Any contributions, large or small, major features, bug fixes, are welcomed and appreciated but will be thoroughly reviewed.

You might also like...
PHPExif is a library which gives you easy access to the EXIF meta-data of an image

PHPExif v0.6.4 PHPExif is a library which gives you easy access to the EXIF meta-data of an image. PHPExif serves as a wrapper around some native or C

Grabs the dominant color or a representative color palette from an image. Uses PHP and GD, Imagick or Gmagick.

Color Thief PHP A PHP class for grabbing the color palette from an image. Uses PHP and GD or Imagick libraries to make it happen. It's a PHP port of t

image sharing site made in PHP just for fun and freetime
image sharing site made in PHP just for fun and freetime

2bart image sharing site made in PHP just for fun and freetime To-do list: upload system [DONE] ✔️ views system [DONE] ✔️ image list system [DONE] ✔️

A simple page view counter that store data as text and shows data as a PNG image

Image Counter A simple page view counter that store data as text and shows the counter as a PNG image.

Picasso is a Laravel Image Management and Optimization Package

Picasso is a Laravel Image Management and Optimization Package. Define image dimensions and options, store uploaded image in multiple dimensions with or without a watermark and retrieve optimized images on your website when needed.

The Gregwar\Image class purpose is to provide a simple object-oriented images handling and caching API
The Gregwar\Image class purpose is to provide a simple object-oriented images handling and caching API

Gregwar's Image class The Gregwar\Image class purpose is to provide a simple object-oriented images handling and caching API. Installation With compos

PHP Image Manipulation

Intervention Image Intervention Image is a PHP image handling and manipulation library providing an easier and expressive way to create, edit, and com

🌄 Perceptual image hashing for PHP
🌄 Perceptual image hashing for PHP

ImageHash A perceptual hash is a fingerprint of a multimedia file derived from various features from its content. Unlike cryptographic hash functions

php-gd based image templates
php-gd based image templates

gdaisy A highly experimental image templating system based on PHP-GD to dynamically generate image banners and covers. Installation 1. Require erikahe

Comments
  • bag: imagejpeg() expects at most 3 arguments, 4 given

    bag: imagejpeg() expects at most 3 arguments, 4 given

    The getData JPG method passes imagejpeg to the getData method. getdate, in turn, runs the imagejpeg function with 4 parameters, but it expects only 3 https://github.com/DantSu/php-image-editor/blob/98985faea4ace4fef932698b9f9a359f9fca8787/src/Image.php#L1218 https://www.php.net/manual/en/function.imagejpeg.php

    opened by dmalapsh 4
  • I am having trouble installing this with composer

    I am having trouble installing this with composer

    I am getting these exceptions while installing them

    Package dantsu/php-image-editor has requirements incompatible with your PHP version, PHP extensions and Composer version:

    • dantsu/php-image-editor 1.0.3 requires php ^7.0 which does not match your installed version 8.1.4.
    • dantsu/php-image-editor 1.0.3 requires ext-gd * but it is not present.

    Help how can I solve these

    opened by Mandeepsinghatintricare 4
  • Add curl option support in Image class

    Add curl option support in Image class

    I'm primarily using php-image-editor because I've been testing out php-osm-static-api. I noticed a couple of things that could help with crafting curl requests, and handling failures. A great example where allowing failOnError is when you want to catch a URL that either isn't resolving, or returning a status that isn't 200.

    My use case would be, if one image processing instance is down, allow fail over to another by using a try catch in my code.

    This pull request contains the following for the reasons stated above.

    • Make it so the curl features of the library support a curl options array for things like timeouts, useragents, SSL Key checks etc.

    • Support fail on error for curl requests as well. The library didn't appear to have any way to bubble up a problem when the curl didn't succeed. $failOnError=true will throw an exception when there is an error.

    opened by davetha 0
Releases(1.4.0)
  • 1.4.0(Nov 9, 2022)

  • 1.3.0(Nov 9, 2022)

    PHP library to easily edit image with GD extension. Resize, crop, merge, draw, and many more options !

    • adding cURL options to throw exception if url cannot be loaded
    Source code(tar.gz)
    Source code(zip)
  • 1.2.0(May 30, 2022)

    PHP library to easily edit image with GD extension. Resize, crop, merge, draw, and many more options !

    • add setOpacity option
    • Fix alpha mask issue
    • Fix getData issue
    Source code(tar.gz)
    Source code(zip)
  • 1.1.1(May 24, 2022)

  • 1.1.0(May 24, 2022)

  • 1.0.5(May 11, 2022)

  • 1.0.4(May 10, 2022)

  • 1.0.3(Nov 22, 2021)

    PHP library to easily edit image with GD extension. Resize, crop, merge, draw, and many more options !

    • Fix bug from ::getAngleAndLengthFromPoints() method
    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(Sep 8, 2021)

  • 1.0.0(Sep 8, 2021)

Owner
Franck Alary
Web and mobile app developer.
Franck Alary
PHP library to resize, scale and crop images.

PHP library to resize, scale and crop images.

Gumlet 1.1k Jan 3, 2023
Image Cache is a very simple PHP class that accepts an image source and will compress and cache the file, move it to a new directory, and returns the new source for the image.

NO LONGER MAINTAINED!!! Image Cache v. 1.0.0 Image Cache is a very simple PHP class that accepts an image source and will compress and cache the file,

Erik Nielsen 455 Dec 30, 2022
Image Resize Middleware for Slim Framework

Image Resize Middleware for Slim This middleware implements automatic image resizing based on image filename. Install You can install latest version u

Mika Tuupola 61 Apr 12, 2022
A Laravel Gravatar package for retrieving gravatar image URLs or checking the existance of an image.

Gravatar for Laravel 5.x, 6, 7 and 8 Installation First, pull in the package through Composer via the command line: composer require creativeorange/gr

Creativeorange 477 Dec 1, 2022
This plugin adds a new image style for the Core Image block.

This plugin adds a new image style for the Core Image block. Introduction How to use? Go to Gutenberg Editor and add a image block. e.g. Add new image

Mahesh Waghmare 3 Feb 17, 2022
Image manager extension for the Yii PHP framework.

yii-imagemanager Image manager extension for the Yii PHP framework. Introduction I started this project to reduce the need for boilerplate code when w

Christoffer Niska 23 Aug 28, 2020
Image optimization / compression library. This library is able to optimize png, jpg and gif files in very easy and handy way. It uses optipng, pngquant, pngcrush, pngout, gifsicle, jpegoptim and jpegtran tools.

Image Optimizer This library is handy and very easy to use optimizer for image files. It uses optipng, pngquant, jpegoptim, svgo and few more librarie

Piotr Śliwa 879 Dec 30, 2022
PHP 5.3 Object Oriented image manipulation library

Imagine Tweet about it using the #php_imagine hashtag. Image manipulation library for PHP 5.3 inspired by Python's PIL and other image libraries. Requ

Bulat Shakirzyanov 4.3k Jan 6, 2023
PHP Thumb is a light-weight image manipulation library aimed at thumbnail generation

PHP Thumb NOTICE - This project was recently updated to 2.0 and is PSR-0 compliant and supports Composer integration. Some parts of the documentation

Ian Selby 985 Dec 4, 2022
Wonderfully easy on-demand image manipulation library with an HTTP based API.

Glide Glide is a wonderfully easy on-demand image manipulation library written in PHP. Its straightforward API is exposed via HTTP, similar to cloud i

The League of Extraordinary Packages 2.4k Dec 19, 2022