PHP Classes
elePHPant
Icontem

File: docs/getting-started.md

Recommend this page to a friend!
  Classes of Jose Luis Quintana  >  GImage  >  docs/getting-started.md  >  Download  
File: docs/getting-started.md
Role: Example script
Content type: text/markdown
Description: Example script
Class: GImage
Create graphic images with a fluent interface
Author: By
Last change:
Date: 5 months ago
Size: 855 bytes
 

Contents

Class file image Download

Getting started

Installation

!!! tip "Requirements"

GImage requires [PHP 7.0+][1] and latest [GD Extension][2].

Make sure if [GD extension][2] is loaded. You can verify it using the following command:

php -r "var_dump(extension_loaded('gd'));"
# bool(true)

Then install GImage via [Composer][3]:

composer require joseluisq/gimage

[1]: http://php.net/manual/en/migration70.new-features.php [2]: http://php.net/manual/en/book.image.php [3]: https://getcomposer.org/

Usage

Loading an external PNG image and saving 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');