PHP Classes
elePHPant
Icontem

File: docs/examples/swapping-formats.md

Recommend this page to a friend!
  Classes of Jose Luis Quintana  >  GImage  >  docs/examples/swapping-formats.md  >  Download  
File: docs/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: 5 months ago
Size: 587 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 outputting 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();