PHP Classes

GImage PHP Canvas to Image: Create and compose canvas images from other images

Recommend this page to a friend!
  Info   View files Example   View files View files (48)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2023-01-18 (2 days ago) RSS 2.0 feedStarStarStarStar 65%Total: 565 This week: 3All time: 5,387 This week: 56Up
Version License PHP version Categories
canvas-image 2.0.16MIT/X Consortium ...5.5PHP 5, Graphics
Description Author

This package can create and compose canvas images from other images.

It provides classes for creating image objects defined by colored rectangles, images from files and text.

An additional canvas class can compose complex images using images defined by the other classes easier.

The composed images may be saved to files in the PNG and JPEG formats or displayed as the current script output.

Picture of Jose Luis Quintana
  Performance   Level  
Name: Jose Luis Quintana <contact>
Classes: 2 packages by
Country: Peru Peru

Details

GImage

Build Status ![](https://packagist.org/packages/joseluisq/gimage) Latest Unstable Version Total Downloads License

> A PHP library for easy image handling. ?

__GImage__ is a simple and small library based on PHP Image Processing and GD for processing images easily.

A simple presentation card with GImage

_Presentation card built with GImage - View code example_

Features

  • Load an image from a local path, URL or image resource.
  • Create shapes such as rectangles or ellipses with opacity.
  • Resize, scale or crop images proportionally.
  • Rotate images, shapes or texts.
  • Embed text with custom TTF fonts.
  • Compose a pool of images with `Canvas`.
  • Swap image formats such as JPEG, PNG or GIF.
  • Save images locally or output them on the browser.
  • Save several copies of the same image.
  • Render an image in memory and return its resource.

Requirements

GImage requires PHP 7.4 or a recent PHP version with the latest GD Extension.

Install

composer require joseluisq/gimage

Usage

Load an external PNG image and save it as JPG:

<?php

use GImage\Image;

// PNG image (600x199)
$url = 'https://i.imgur.com/G5MR088.png';

$arch = new Image();
$arch
    // Load from URL
    ->load($url)
    // Scale to 50% (300x99)
    ->scale(0.5)
    // Change the format to JPG
    ->toJPG()
    // Saving in local path
    ->save('arch.jpg');

See GImage Website for detailed usage instructions and more advanced examples.

Changelog

Check out the CHANGELOG.md file.

Examples

See code examples directory.

Development

Run tests

Via Composer

composer install
composer run-script test

Via Docker (multi PHP versions test)

make docker-tests

Contribution

Feel free to send some Pull request or file an issue.

License

This work is primarily distributed under the terms of the MIT license.

©2015-present Jose Quintana

  Files folder image Files  
File Role Description
Files folder image.github (1 directory)
Files folder imagedocs (2 files, 1 directory)
Files folder imageexamples (11 files)
Files folder imagesrc (5 files)
Files folder imagetests (2 files)
Accessible without login Plain text file .php-cs-fixer.dist.php Example Example script
Accessible without login Plain text file CHANGELOG.md Example Example script
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE-MIT Lic. License text
Accessible without login Plain text file Makefile Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Data Auxiliary data

  Files folder image Files  /  .github  
File Role Description
Files folder imageworkflows (1 file)

  Files folder image Files  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file devel.yml Data Auxiliary data

  Files folder image Files  /  docs  
File Role Description
Files folder imagecontent (4 files, 3 directories)
  Accessible without login Plain text file mkdocs.yml Data Auxiliary data
  Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  docs  /  content  
File Role Description
Files folder imageassets (1 file)
Files folder imageclasses (4 files)
Files folder imageexamples (11 files)
  Accessible without login Plain text file api.md Data Auxiliary data
  Accessible without login Plain text file build-documentation.md Data Auxiliary data
  Accessible without login Plain text file getting-started.md Example Example script
  Accessible without login Plain text file index.md Data Auxiliary data

  Files folder image Files  /  docs  /  content  /  assets  
File Role Description
  Accessible without login Plain text file style.css Data Auxiliary data

  Files folder image Files  /  docs  /  content  /  classes  
File Role Description
  Accessible without login Plain text file canvas.md Example Example script
  Accessible without login Plain text file figure.md Example Example script
  Accessible without login Plain text file image.md Example Example script
  Accessible without login Plain text file text.md Example Example script

  Files folder image Files  /  docs  /  content  /  examples  
File Role Description
  Accessible without login Plain text file composing-with-canvas.md Example Example script
  Accessible without login Plain text file creating-a-presentation-card.md Example Example script
  Accessible without login Plain text file creating-figures.md Example Example script
  Accessible without login Plain text file cropping.md Example Example script
  Accessible without login Plain text file image-resource-loading.md Example Example script
  Accessible without login Plain text file index.md Data Auxiliary data
  Accessible without login Plain text file render-images-in-memory.md Example Example script
  Accessible without login Plain text file resizing.md Example Example script
  Accessible without login Plain text file rotation.md Example Example script
  Accessible without login Plain text file swapping-formats.md Example Example script
  Accessible without login Plain text file text-embedding.md Example Example script

  Files folder image Files  /  examples  
File Role Description
  Accessible without login Plain text file card.php Example Example script
  Accessible without login Plain text file crop.php Example Example script
  Accessible without login Plain text file ellipse.php Example Example script
  Accessible without login Plain text file jpg2png.php Example Example script
  Accessible without login Plain text file README.md Doc. Documentation
  Accessible without login Plain text file rectangle.php Example Example script
  Accessible without login Plain text file render.php Example Example script
  Accessible without login Plain text file resource.php Example Example script
  Accessible without login Plain text file rotate.php Example Example script
  Accessible without login Plain text file text.php Example Example script
  Accessible without login Plain text file _config.php Aux. Auxiliary script

  Files folder image Files  /  src  
File Role Description
  Plain text file Canvas.php Class Class source
  Plain text file Figure.php Class Class source
  Plain text file Image.php Class Class source
  Plain text file Text.php Class Class source
  Plain text file Utils.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Accessible without login Plain text file bootstrap.php Aux. Auxiliary script
  Plain text file GImageTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:565
This week:3
All time:5,387
This week:56Up
User Ratings User Comments (1)
 All time
Utility:93%StarStarStarStarStar
Consistency:93%StarStarStarStarStar
Documentation:-
Examples:87%StarStarStarStarStar
Tests:-
Videos:-
Overall:65%StarStarStarStar
Rank:826
 
It is a nice Widget
8 years ago (Thomas Stoffregen)
80%StarStarStarStarStar