PHP Classes
elePHPant
Icontem

File: examples/resource.php

Recommend this page to a friend!
  Classes of Jose Luis Quintana  >  GImage PHP Canvas to Image  >  examples/resource.php  >  Download  
File: examples/resource.php
Role: Example script
Content type: text/plain
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: 853 bytes
 

Contents

Class file image Download
<?php
/*
 * This file is part of GImage.
 *
 * (c) Josť Luis Quintana <https://git.io/joseluisq>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

/**
 * Render an image from resource.
 *
 * @author Josť Luis Quintana <https://git.io/joseluisq>
 */

namespace GImage\Examples;

use
GImage\Image;

require
__DIR__ . '/_config.php';
require
__DIR__ . '/../tests/bootstrap.php';

// Create a 240x100 image
$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.50)
  ->
toPNG()
  ->
save(__DIR__ . '/rectangle.png');