Skip to content

Getting started

Installation

Requirements

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

Make sure that GD extension is loaded on your system. You can verify it using the following command:

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

Then install GImage via Composer:

composer require joseluisq/gimage

Usage

Loading an external PNG image and saving it as JPG:

<?php

// 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');