PHP Classes

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

Recommend this page to a friend!
  Classes of Jose Luis Quintana   GImage   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
Create graphic images with a fluent interface
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();