Canvases are created using one of the imagecreate* family of functions as imagecreate() (to create an empty canvas) or imagecreatefromjpeg() (to create from an existing Jpeg image)
Both functions return a resource representing the canvas for that image.
<?php
/* Create an new 256 x 256 image canvas */
$img = imagecreate(256, 256);
/* Create a canvas based on a jpeg */
$img2 = imagecreatefromjpeg("/path/to/my/jpeg");
?>
GD can support the loading of a number of formats:
- • imagecreate($width, $height) - Creates an empty canvas
- • imagecreatetruecolor($width, $height) - Creates an empty 24-bit color canvas
- • imagecreatefromjpeg($filename) - Creates a canvas based on a Jpeg image
- • imagecreatefrompng($filename) - Creates a canvas based on a PNG image
- • Similar functions for XPM, WBMP, XBM, and GIF files