IImage
in
Class for basic image manipulation
Tags
Table of Contents
Methods
- centerCrop() : bool
- Crops the image to the middle square. If the image is already square it just returns.
- copy() : IImage
- create a copy of this image
- crop() : bool
- Crops the image from point $x$y with dimension $wx$h.
- cropCopy() : IImage
- create a new cropped copy of this image
- data() : string
- dataMimeType() : string
- fitIn() : bool
- Resizes the image to fit within a boundary while preserving ratio.
- fixOrientation() : bool
- (I'm open for suggestions on better method name ;) Fixes orientation based on EXIF data.
- getOrientation() : int
- (I'm open for suggestions on better method name ;) Get the orientation based on EXIF data.
- height() : int
- Returns the height of the image or -1 if no image is loaded.
- heightTopLeft() : int
- Returns the height when the image orientation is top-left.
- loadFromData() : GdImage|false
- Loads an image from a string of data.
- mimeType() : string|null
- Returns the MIME type of the image or null if no image is loaded.
- preciseResize() : bool
- preciseResizeCopy() : IImage
- create a new resized copy of this image
- readExif() : void
- Reads the EXIF data for an image.
- resize() : bool
- Resizes the image preserving ratio.
- resizeCopy() : IImage
- Resizes the image preserving ratio, returning a new copy
- resource() : false|resource|GdImage
- save() : bool
- Saves the image.
- scaleDownToFit() : bool
- Shrinks the image to fit within a boundary while preserving ratio.
- show() : bool
- Outputs the image.
- valid() : bool
- Determine whether the object contains an image resource.
- width() : int
- Returns the width of the image or -1 if no image is loaded.
- widthTopLeft() : int
- Returns the width when the image orientation is top-left.
Methods
centerCrop()
Crops the image to the middle square. If the image is already square it just returns.
public
centerCrop([int $size = 0 ]) : bool
Parameters
- $size : int = 0
-
maximum size for the result (optional)
Tags
Return values
bool —for success or failure
copy()
create a copy of this image
public
copy() : IImage
Tags
Return values
IImagecrop()
Crops the image from point $x$y with dimension $wx$h.
public
crop(int $x, int $y, int $w, int $h) : bool
Parameters
- $x : int
-
Horizontal position
- $y : int
-
Vertical position
- $w : int
-
Width
- $h : int
-
Height
Tags
Return values
bool —for success or failure
cropCopy()
create a new cropped copy of this image
public
cropCopy(int $x, int $y, int $w, int $h) : IImage
Parameters
- $x : int
-
Horizontal position
- $y : int
-
Vertical position
- $w : int
-
Width
- $h : int
-
Height
Tags
Return values
IImagedata()
public
data() : string
Tags
Return values
string —Returns the raw image data.
dataMimeType()
public
dataMimeType() : string
Tags
Return values
string —Returns the mimetype of the data. Returns null if the data is not valid.
fitIn()
Resizes the image to fit within a boundary while preserving ratio.
public
fitIn(int $maxWidth, int $maxHeight) : bool
Warning: Images smaller than $maxWidth x $maxHeight will end up being scaled up
Parameters
- $maxWidth : int
- $maxHeight : int
Tags
Return values
boolfixOrientation()
(I'm open for suggestions on better method name ;) Fixes orientation based on EXIF data.
public
fixOrientation() : bool
Tags
Return values
boolgetOrientation()
(I'm open for suggestions on better method name ;) Get the orientation based on EXIF data.
public
getOrientation() : int
Tags
Return values
int —The orientation or -1 if no EXIF data is available.
height()
Returns the height of the image or -1 if no image is loaded.
public
height() : int
Tags
Return values
intheightTopLeft()
Returns the height when the image orientation is top-left.
public
heightTopLeft() : int
Tags
Return values
intloadFromData()
Loads an image from a string of data.
public
loadFromData(string $str) : GdImage|false
Parameters
- $str : string
-
A string of image data as read from a file.
Tags
Return values
GdImage|falsemimeType()
Returns the MIME type of the image or null if no image is loaded.
public
mimeType() : string|null
Tags
Return values
string|nullpreciseResize()
public
preciseResize(int $width, int $height) : bool
Parameters
- $width : int
- $height : int
Tags
Return values
boolpreciseResizeCopy()
create a new resized copy of this image
public
preciseResizeCopy(int $width, int $height) : IImage
Parameters
- $width : int
- $height : int
Tags
Return values
IImagereadExif()
Reads the EXIF data for an image.
public
readExif(string $data) : void
Parameters
- $data : string
-
EXIF data
Tags
resize()
Resizes the image preserving ratio.
public
resize(int $maxSize) : bool
Parameters
- $maxSize : int
-
The maximum size of either the width or height.
Tags
Return values
boolresizeCopy()
Resizes the image preserving ratio, returning a new copy
public
resizeCopy(int $maxSize) : IImage
Parameters
- $maxSize : int
-
The maximum size of either the width or height.
Tags
Return values
IImageresource()
public
resource() : false|resource|GdImage
Tags
Return values
false|resource|GdImage —Returns the image resource if any
save()
Saves the image.
public
save([string $filePath = null ][, string $mimeType = null ]) : bool
Parameters
- $filePath : string = null
- $mimeType : string = null
Tags
Return values
boolscaleDownToFit()
Shrinks the image to fit within a boundary while preserving ratio.
public
scaleDownToFit(int $maxWidth, int $maxHeight) : bool
Parameters
- $maxWidth : int
- $maxHeight : int
Tags
Return values
boolshow()
Outputs the image.
public
show([string|null $mimeType = null ]) : bool
Parameters
- $mimeType : string|null = null
Tags
Return values
boolvalid()
Determine whether the object contains an image resource.
public
valid() : bool
Tags
Return values
boolwidth()
Returns the width of the image or -1 if no image is loaded.
public
width() : int
Tags
Return values
intwidthTopLeft()
Returns the width when the image orientation is top-left.
public
widthTopLeft() : int