PHP Classes

GImage: Create graphic images with a fluent interface

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 43%Total: 192 All time: 8,567 This week: 455Up
Version License PHP version Categories
gimage 2.0.15MIT/X Consortium ...5.5PHP 5, Graphics
Description 

Author

This class can Create graphic images with a fluent interface.

It provides a base class that can load and save images from file in different formats like GIF, PNG and JPEG. It can also crop, resize and rotate images.

There are several sub-classes that can create images with text, canvas shapes, and rectangular figures.

Picture of Jose Luis Quintana
  Performance   Level  
Name: Jose Luis Quintana <contact>
Classes: 2 packages by
Country: Peru Peru
Age: ???
All time rank: 28386 in Peru Peru
Week rank: 195 Up1 in Peru Peru Up

Example

<?php
/*
 * This file is part of GImage.
 *
 * (c) Jose Quintana <https://joseluisq.net>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

/**
 * Creating a Presentation Card.
 *
 * @author Jose Quintana <https://joseluisq.net>
 */

namespace GImage\Examples;

use
GImage\Image;
use
GImage\Text;
use
GImage\Figure;
use
GImage\Canvas;

require
__DIR__ . '/_config.php';
require
__DIR__ . '/../tests/bootstrap.php';

// Creating an avatar image
$avatar_image = new Image();
$avatar_image
   
// Image size (500x500)
   
->load('https://i.imgur.com/vLXIIoY.jpg')
    ->
centerCrop(100, 100)
    ->
setTop(60)
    ->
setLeft(70);

$about_text = new Text("MY AWESOME PRESENTATION CARD\n~ BY GIMAGE ~");
$about_text->setSize(16)
    ->
setWidth(300)
    ->
setLeft(210)
    ->
setLineHeight(1.5)
    ->
setTop(75)
    ->
setColor(204, 164, 116)
    ->
setFontface(BASE_PATH . '/fonts/Lato-Lig.ttf');

$twitter_text = new Text('@joseluisq/gimage');
$twitter_text
   
->setSize(11)
    ->
setWidth(70)
    ->
setLeft(410)
    ->
setTop(210)
    ->
setColor(130, 127, 125)
    ->
setFontface(BASE_PATH . '/fonts/Lato-Reg.ttf');

$canvas_figure = new Figure(550, 250);
$canvas_figure
   
->setBackgroundColor(47, 42, 39)
    ->
create();

$avatar_box = new Figure($avatar_image->getWidth() + 16, $avatar_image->getHeight() + 17);
$avatar_box
   
->setBackgroundColor(63, 56, 52)
    ->
setLeft($avatar_image->getLeft() - 7)
    ->
setTop($avatar_image->getTop() - 8)
    ->
create();

$avatar_box2 = new Figure($avatar_image->getWidth() + 3, $avatar_image->getHeight() + 19);
$avatar_box2
   
->setBackgroundColor(79, 72, 67)
    ->
setLeft($avatar_image->getLeft() + 7)
    ->
setTop($avatar_image->getTop() - 9)
    ->
create();

$avatar_box3 = new Figure(120, 240);
$avatar_box3
   
->setBackgroundColor(63, 56, 52)
    ->
create();

$line_vertical = new Figure(600, 10);
$line_vertical
   
->setBackgroundColor(119, 99, 77)
    ->
setTop(240)
    ->
create();

$line_horizontal = new Figure(1, 240);
$line_horizontal
   
->setBackgroundColor(79, 72, 67)
    ->
setLeft(120)
    ->
create();

$canvas = new Canvas($canvas_figure);
$canvas
   
->append([
       
$line_horizontal,
       
$avatar_box2,
       
$avatar_box3,
       
$avatar_box,
       
$avatar_image,
       
$about_text,
       
$twitter_text,
       
$line_vertical
   
])
    ->
setQuality(100)
    ->
toPNG()
    ->
draw()
    ->
save(__DIR__ . '/card.png');


  Files folder image Files (50)  
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 .gitattributes Data Auxiliary data
Accessible without login Plain text file .gitignore Data Auxiliary data
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 Example Example script

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

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

  Files folder image Files (50)  /  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 (50)  /  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 (50)  /  docs  /  content  /  assets  
File Role Description
  Accessible without login Plain text file style.css Data Auxiliary data

  Files folder image Files (50)  /  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 (50)  /  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 (50)  /  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 (50)  /  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 (50)  /  tests  
File Role Description
  Accessible without login Plain text file bootstrap.php Aux. Auxiliary script
  Plain text file GImageTest.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:192
This week:0
All time:8,567
This week:455Up
 User Ratings  
 
 All time
Utility:62%StarStarStarStar
Consistency:68%StarStarStarStar
Documentation:-
Examples:50%StarStarStar
Tests:-
Videos:-
Overall:43%StarStarStar
Rank:3600