PHP Classes
elePHPant
Icontem

File: docs/examples/image-resource-loading.md

Recommend this page to a friend!
  Classes of Jose Luis Quintana  >  GImage PHP Canvas to Image  >  docs/examples/image-resource-loading.md  >  Download  
File: docs/examples/image-resource-loading.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: 545 bytes
 

 

Contents

Class file image Download

Image resource loading

The following example loads an image resource using the load($src) method.

<?php

use GImage\Image;

// Create a image rectangle (240x100)
$width = 240;
$height = 100;
$rectangle = imagecreatetruecolor($width, $height);
$green = imagecolorallocate($rectangle, 0, 255, 0);
imagefilledrectangle($rectangle, 0, 0, $width, $height, $green);

// Load and process the rectangle image resource
$img = new Image();
$img
  ->load($rectangle)
  // scale to 50%
  ->scale(0.5)
  ->toPNG()
  ->save('rectangle.png');