PHP Classes

File: docs/content/examples/swapping-formats.md

Recommend this page to a friend!
  Classes of Jose Luis Quintana   GImage PHP Canvas to Image   docs/content/examples/swapping-formats.md   Download  
File: docs/content/examples/swapping-formats.md
Role: Example script
Content type: text/markdown
Description: Example script
Class: GImage PHP Canvas to Image
Create and compose canvas images from other images
Author: By
Last change:
Date: 1 year ago
Size: 583 bytes
 

Contents

Class file image Download

Swapping formats

It's possible to swapping image formats. The following example loads a PNG image and save it as JPG.

<?php

use GImage\Image;

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

$arch_img = new Image();
$arch_img
    ->load($arch_url)
    ->crop(20, 20)
    ->toJPG()
    ->save('arch.jpg');

Or output it on browser:

<?php

use GImage\Image;

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

$arch_img = new Image();
$arch_img
    ->load($arch_url)
    ->scale(0.5)
    ->toJPG()
    ->output();