PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Jose Luis Quintana   GImage PHP Canvas to Image   README.md   Download  
File: README.md
Role: Auxiliary data
Content type: text/markdown
Description: Auxiliary data
Class: GImage PHP Canvas to Image
Create and compose canvas images from other images
Author: By
Last change: refactor: minor project tasks tweaks [skip ci]
docs: improve example pages and code files
docs: update php 7.4+ requirements [skip ci]
feat: add php 8.1 support

- add php 8.1 ci and tests
- fixes missing types casting
refactor: github actions for testing on php 7.4 and 8.0

it also:
- applies code formatting via `php-cs-fixer`
- removes some project files
- Removes Travis ci config
Date: 1 year ago
Size: 2,988 bytes
 

Contents

Class file image Download

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