API - XOOPS 2.5.11 Beta 2
By monxoops.fr
WideImage Class Reference

Static Public Member Functions

static version ()
 
static path ()
 
static checkGD ()
 
static registerCustomMapper ($mapper_class_name, $mime_type, $extension)
 
static load ($source)
 
static loadFromFile ($uri)
 
static loadFromString ($string)
 
static loadFromHandle ($handle)
 
static loadFromUpload ($field_name, $index=null)
 
static createPaletteImage ($width, $height)
 
static createTrueColorImage ($width, $height)
 
static isValidImageHandle ($handle)
 
static assertValidImageHandle ($handle)
 

Data Fields

const SIDE_TOP_LEFT = 1
 
const SIDE_TOP = 2
 
const SIDE_TOP_RIGHT = 4
 
const SIDE_RIGHT = 8
 
const SIDE_BOTTOM_RIGHT = 16
 
const SIDE_BOTTOM = 32
 
const SIDE_BOTTOM_LEFT = 64
 
const SIDE_LEFT = 128
 
const SIDE_ALL = 255
 

Static Protected Attributes

static $path = null
 

Member Function Documentation

◆ assertValidImageHandle()

static assertValidImageHandle (   $handle)
static

Throws exception if the handle isn't a valid GD resource

Parameters
mixed$handleThe variable to check

◆ checkGD()

static checkGD ( )
static

Checks whether the gd library is loaded, and throws an exception otherwise

◆ createPaletteImage()

static createPaletteImage (   $width,
  $height 
)
static

Factory method for creating a palette image

Parameters
int$width
int$height
Returns
\WideImage\PaletteImage
Here is the call graph for this function:

◆ createTrueColorImage()

static createTrueColorImage (   $width,
  $height 
)
static

Factory method for creating a true-color image

Parameters
int$width
int$height
Returns
\WideImage\TrueColorImage
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isValidImageHandle()

static isValidImageHandle (   $handle)
static

Check whether the given handle is a valid GD resource

Parameters
mixed$handleThe variable to check
Returns
bool

◆ load()

static load (   $source)
static

Loads an image from a file, URL, HTML input file field, binary string, or a valid image handle. The image format is auto-detected.

Currently supported formats: PNG, GIF, JPG, BMP, TGA, GD, GD2.

This function analyzes the input and decides whether to use WideImage::loadFromHandle(), WideImage::loadFromFile(), WideImage::loadFromUpload() or WideImage::loadFromString(), all of which you can also call directly to spare WideImage some guessing.

Arrays are supported for upload fields; it returns an array of loaded images. To load only a single image from an array field, use WideImage::loadFromUpload('img', $i), where $i is the index of the image you want to load.

$img = WideImage::load('http://url/image.png'); // image URL $img = WideImage::load('/path/to/image.png'); // local file path $img = WideImage::load('img'); // upload field name $img = WideImage::load(imagecreatetruecolor(10, 10)); // a GD resource $img = WideImage::load($image_data); // binary string containing image data

Parameters
mixed$sourceFile name, url, HTML file input field name, binary string, or a GD image resource
Returns
\WideImage\Image|\WideImage\PaletteImage|\WideImage\TrueColorImage

◆ loadFromFile()

static loadFromFile (   $uri)
static

Create and load an image from a file or URL. The image format is auto-detected.

Parameters
string$uriFile or url
Returns
\WideImage\Image|\WideImage\PaletteImage|\WideImage\TrueColorImage

◆ loadFromHandle()

static loadFromHandle (   $handle)
static

Create and load an image from an image handle.

Note: the resulting image object takes ownership of the passed handle. When the newly-created image object is destroyed, the handle is destroyed too, so it's not a valid image handle anymore. In order to preserve the handle for use after object destruction, you have to call \WideImage\Image::releaseHandle() on the created image instance prior to its destruction.

$handle = imagecreatefrompng('file.png'); $image = WideImage::loadFromHandle($handle);

Parameters
resource$handleA valid GD image resource
Returns
\WideImage\Image|\WideImage\PaletteImage|\WideImage\TrueColorImage

◆ loadFromString()

static loadFromString (   $string)
static

Create and load an image from a string. Format is auto-detected.

Parameters
string$stringBinary data, i.e. from BLOB field in the database
Returns
\WideImage\Image|\WideImage\PaletteImage|\WideImage\TrueColorImage
Here is the call graph for this function:

◆ loadFromUpload()

static loadFromUpload (   $field_name,
  $index = null 
)
static

This method loads a file from the $_FILES array. The image format is auto-detected.

You only have to pass the field name as the parameter. For array fields, this function will return an array of image objects, unless you specify the $index parameter, which will load the desired image.

Parameters
$field_nameName of the key in $_FILES array
int$indexThe index of the file to load (if the input field is an array)
Returns
\WideImage\Image The loaded image

◆ path()

static path ( )
static

Returns the path to the library

Returns
string

◆ registerCustomMapper()

static registerCustomMapper (   $mapper_class_name,
  $mime_type,
  $extension 
)
static

Registers a custom mapper for image loading and saving

Example: \WideImage\WideImage::registerCustomMapper('\WideImage\Mapper\TGA', 'image/tga', 'tga');

Parameters
string$mapper_class_name
string$mime_type
string$extension
Here is the call graph for this function:

◆ version()

static version ( )
static

Returns the library version

Returns
string The library version

Field Documentation

◆ $path

$path = null
staticprotected

◆ SIDE_ALL

const SIDE_ALL = 255

◆ SIDE_BOTTOM

const SIDE_BOTTOM = 32

◆ SIDE_BOTTOM_LEFT

const SIDE_BOTTOM_LEFT = 64

◆ SIDE_BOTTOM_RIGHT

const SIDE_BOTTOM_RIGHT = 16

◆ SIDE_LEFT

const SIDE_LEFT = 128

◆ SIDE_RIGHT

const SIDE_RIGHT = 8

◆ SIDE_TOP

const SIDE_TOP = 2

◆ SIDE_TOP_LEFT

const SIDE_TOP_LEFT = 1

◆ SIDE_TOP_RIGHT

const SIDE_TOP_RIGHT = 4

The documentation for this class was generated from the following file: