RSI helpers  0.1
RSI helpers
Image Class Reference

Image helpers. More...

Static Public Member Functions

static fromFile ($filename)
 Create an image resource from file. More...
 
static dataUri ($image, $type=IMAGETYPE_JPEG, $quality=75)
 Convert an image resource to base64 encoded uri. More...
 
static scaleBox ($image, $width, $height, $options=0, $mode=IMG_BILINEAR_FIXED)
 Scale an image resource to fit a certain box size, maintaining aspect ratio. More...
 

Data Fields

const IMAGE_SCALE_INSIDE = 1
 Scale image inside box (normally it will scale to fit at least the box). More...
 
const IMAGE_SCALE_ONLY_SMALLER = 2
 Only make an image smaller, not larger. More...
 

Detailed Description

Image helpers.

Definition at line 8 of file Image.php.

Member Function Documentation

◆ dataUri()

static dataUri (   $image,
  $type = IMAGETYPE_JPEG,
  $quality = 75 
)
static

Convert an image resource to base64 encoded uri.

Parameters
resource$imageImage resource.
string$typeOutput image type (see PHP's IMAGETYPE_* constants).
int$qualityQuality for JPEG or PNG format.
Returns
string False if unsupported type.

Definition at line 29 of file Image.php.

◆ fromFile()

static fromFile (   $filename)
static

Create an image resource from file.

Parameters
string$filenameImage filename.
Returns
resource Image resource (false if the image type is unsupported, the data is not in a recognised format, or the image is corrupt and cannot be loaded).

Definition at line 19 of file Image.php.

◆ scaleBox()

static scaleBox (   $image,
  $width,
  $height,
  $options = 0,
  $mode = IMG_BILINEAR_FIXED 
)
static

Scale an image resource to fit a certain box size, maintaining aspect ratio.

Parameters
resource$imageImage resource.
int$widthBox width.
int$heightBox height.
int$optionsSee IMAGE_SCALE_* constants.
int$modeScaling mode (see http://php.net/manual/en/function.imagescale.php).
Returns
resource Scaled image resource, or false on failure (including image smaller than requested dimension and IMAGE_SCALE_ONLY_SMALLER in options).

Definition at line 57 of file Image.php.

Field Documentation

◆ IMAGE_SCALE_INSIDE

const IMAGE_SCALE_INSIDE = 1

Scale image inside box (normally it will scale to fit at least the box).

Definition at line 10 of file Image.php.

◆ IMAGE_SCALE_ONLY_SMALLER

const IMAGE_SCALE_ONLY_SMALLER = 2

Only make an image smaller, not larger.

Definition at line 11 of file Image.php.


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