Documentation

Gd extends AbstractAdapter
in package

Gd adapter class

Tags
category

Pop

author

Nick Sagona, III dev@nolainteractive.com

copyright

Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com)

license

http://www.popphp.org/license New BSD License

version
4.0.0

Table of Contents

Constants

IMAGE_CMYK  = 3
IMAGE_GRAY  = 1
Colorspace constants
IMAGE_RGB  = 2

Properties

$adjust  : AdjustInterface|null
Image adjust object
$colorspace  : int
Image colorspace
$draw  : DrawInterface|null
Image draw object
$effect  : EffectInterface|null
Image effect object
$exif  : array<string|int, mixed>
EXIF data
$filter  : FilterInterface|null
Image filter object
$format  : string
Image format
$height  : int
Image height
$indexed  : bool
Index color flag
$layer  : LayerInterface|null
Image layer object
$name  : string
Image name
$quality  : int
Image quality
$resource  : mixed
Image resource
$type  : TypeInterface|null
Image type object
$width  : int
Image width

Methods

__construct()  : mixed
Constructor
__get()  : mixed
Magic get method to return a manipulation object
__toString()  : string
Output the image
adjust()  : AdjustInterface
Get the image adjust object
convert()  : Gd
Convert the image object to another format
create()  : Gd
Create a new image resource
createColor()  : mixed
Create and return a color
createIndex()  : Gd
Create a new image resource
createResource()  : void
Create the image resource
crop()  : Gd
Crop the image object to a image whose dimensions are based on the value of the $wid and $hgt argument. The optional $x and $y arguments allow for the adjustment of the crop to select a certain area of the image to be cropped.
cropThumb()  : Gd
Crop the image object to a square image whose dimensions are based on the value of the $px argument. The optional $offset argument allows for the adjustment of the crop to select a certain area of the image to be cropped.
destroy()  : void
Destroy the image object and the related image file directly
draw()  : DrawInterface
Get the image draw object
effect()  : EffectInterface
Get the image effect object
filter()  : FilterInterface
Get the image filter object
flip()  : Gd
Method to flip the image over the x-axis
flop()  : Gd
Method to flip the image over the y-axis
getColorspace()  : int
Get the colorspace
getExif()  : array<string|int, mixed>
Get the image EXIF data
getFormat()  : string
Get the image format
getHeight()  : int
Get the image height
getName()  : string
Get the image name
getQuality()  : int
Get the image quality
getResource()  : mixed
Get the image resource
getWidth()  : int
Get the image width
hasResource()  : bool
Determine if there is an image resource
isCmyk()  : bool
Determine if the image is CMYK
isGray()  : bool
Determine if the image is grayscale
isIndexed()  : bool
Determine if the image is index color
isRgb()  : bool
Determine if the image is RGB
layer()  : LayerInterface
Get the image layer object
load()  : Gd
Load the image resource from the existing image file
loadFromString()  : Gd
Load the image resource from data
outputToHttp()  : void
Output the image object directly to HTTP
outputToRawString()  : string|false
Output the image object to a raw string
resize()  : Gd
Resize the image object, allowing for the largest dimension to be scaled to the value of the $px argument.
resizeToHeight()  : Gd
Resize the image object to the height parameter passed
resizeToWidth()  : Gd
Resize the image object to the width parameter passed
rotate()  : Gd
Rotate the image object
scale()  : Gd
Scale the image object, allowing for the dimensions to be scaled proportionally to the value of the $scale argument.
sendHeaders()  : void
Send image headers the image
setQuality()  : static
Set the image quality
type()  : TypeInterface
Get the image type object
writeToFile()  : void
Write the image object to a file on disk
copyImage()  : void
Copy the image resource to the image output resource with the set parameters
generateImage()  : void
Parse the image data
parseImage()  : void
Parse the image data

Constants

Properties

Methods

__construct()

Constructor

public __construct() : mixed

Instantiate an image object based on either a pre-existing image file on disk, or a new image file.

__get()

Magic get method to return a manipulation object

public __get(string $name) : mixed
Parameters
$name : string

__toString()

Output the image

public __toString() : string
Return values
string

convert()

Convert the image object to another format

public convert(string $type) : Gd
Parameters
$type : string
Tags
throws
Exception
Return values
Gd

create()

Create a new image resource

public create([int|null $width = null ][, int|null $height = null ][, string|null $name = null ]) : Gd
Parameters
$width : int|null = null
$height : int|null = null
$name : string|null = null
Tags
throws
Exception
Return values
Gd

createColor()

Create and return a color

public createColor([ColorInterface|null $color = null ][, int|null $alpha = null ]) : mixed
Parameters
$color : ColorInterface|null = null
$alpha : int|null = null
Tags
throws
Exception

createIndex()

Create a new image resource

public createIndex([int|null $width = null ][, int|null $height = null ][, string|null $name = null ]) : Gd
Parameters
$width : int|null = null
$height : int|null = null
$name : string|null = null
Tags
throws
Exception
Return values
Gd

createResource()

Create the image resource

public createResource() : void

crop()

Crop the image object to a image whose dimensions are based on the value of the $wid and $hgt argument. The optional $x and $y arguments allow for the adjustment of the crop to select a certain area of the image to be cropped.

public crop(int $w, int $h[, int $x = 0 ][, int $y = 0 ]) : Gd
Parameters
$w : int
$h : int
$x : int = 0
$y : int = 0
Return values
Gd

cropThumb()

Crop the image object to a square image whose dimensions are based on the value of the $px argument. The optional $offset argument allows for the adjustment of the crop to select a certain area of the image to be cropped.

public cropThumb(int $px[, int|null $offset = null ]) : Gd
Parameters
$px : int
$offset : int|null = null
Return values
Gd

destroy()

Destroy the image object and the related image file directly

public destroy([bool $delete = false ]) : void
Parameters
$delete : bool = false

flip()

Method to flip the image over the x-axis

public flip() : Gd
Return values
Gd

flop()

Method to flip the image over the y-axis

public flop() : Gd
Return values
Gd

getColorspace()

Get the colorspace

public getColorspace() : int
Return values
int

getExif()

Get the image EXIF data

public getExif() : array<string|int, mixed>
Return values
array<string|int, mixed>

getFormat()

Get the image format

public getFormat() : string
Return values
string

getHeight()

Get the image height

public getHeight() : int
Return values
int

getName()

Get the image name

public getName() : string
Return values
string

getQuality()

Get the image quality

public getQuality() : int
Return values
int

getWidth()

Get the image width

public getWidth() : int
Return values
int

hasResource()

Determine if there is an image resource

public hasResource() : bool
Return values
bool

isCmyk()

Determine if the image is CMYK

public isCmyk() : bool
Return values
bool

isGray()

Determine if the image is grayscale

public isGray() : bool
Return values
bool

isIndexed()

Determine if the image is index color

public isIndexed() : bool
Return values
bool

isRgb()

Determine if the image is RGB

public isRgb() : bool
Return values
bool

load()

Load the image resource from the existing image file

public load([string|null $name = null ]) : Gd
Parameters
$name : string|null = null
Tags
throws
Exception
Return values
Gd

loadFromString()

Load the image resource from data

public loadFromString(string $data[, string|null $name = null ]) : Gd
Parameters
$data : string
$name : string|null = null
Tags
throws
Exception
Return values
Gd

outputToHttp()

Output the image object directly to HTTP

public outputToHttp([int|null $quality = null ][, string|null $to = null ][, bool $download = false ][, bool $sendHeaders = true ][, array<string|int, mixed> $headers = [] ]) : void
Parameters
$quality : int|null = null
$to : string|null = null
$download : bool = false
$sendHeaders : bool = true
$headers : array<string|int, mixed> = []
Tags
throws
Exception

outputToRawString()

Output the image object to a raw string

public outputToRawString([int $quality = 100 ]) : string|false
Parameters
$quality : int = 100
Tags
throws
Exception
Return values
string|false

resize()

Resize the image object, allowing for the largest dimension to be scaled to the value of the $px argument.

public resize(int $px) : Gd
Parameters
$px : int
Return values
Gd

resizeToHeight()

Resize the image object to the height parameter passed

public resizeToHeight(int $h) : Gd
Parameters
$h : int
Return values
Gd

resizeToWidth()

Resize the image object to the width parameter passed

public resizeToWidth(int $w) : Gd
Parameters
$w : int
Return values
Gd

rotate()

Rotate the image object

public rotate(int $degrees[, ColorInterface|null $bgColor = null ][, int|null $alpha = null ]) : Gd
Parameters
$degrees : int
$bgColor : ColorInterface|null = null
$alpha : int|null = null
Return values
Gd

scale()

Scale the image object, allowing for the dimensions to be scaled proportionally to the value of the $scale argument.

public scale(float $scale) : Gd
Parameters
$scale : float
Return values
Gd

sendHeaders()

Send image headers the image

public sendHeaders([string|null $to = null ][, bool $download = false ][, array<string|int, mixed> $additionalHeaders = [] ]) : void
Parameters
$to : string|null = null
$download : bool = false
$additionalHeaders : array<string|int, mixed> = []

setQuality()

Set the image quality

public setQuality(int $quality) : static
Parameters
$quality : int
Tags
oaram

int $quality

Return values
static

writeToFile()

Write the image object to a file on disk

public writeToFile([string|null $to = null ][, int|null $quality = null ]) : void
Parameters
$to : string|null = null
$quality : int|null = null
Tags
throws
Exception

copyImage()

Copy the image resource to the image output resource with the set parameters

protected copyImage(int $w, int $h[, int $x = 0 ][, int $y = 0 ]) : void
Parameters
$w : int
$h : int
$x : int = 0
$y : int = 0

generateImage()

Parse the image data

protected generateImage(int $quality[, string|null $to = null ]) : void
Parameters
$quality : int
$to : string|null = null

parseImage()

Parse the image data

protected parseImage(array<string|int, mixed> $size, string $data) : void
Parameters
$size : array<string|int, mixed>
$data : string

        
On this page

Search results