ImageResource
class ImageResource (View source)
An object representation of GD's native image resources.
Note: Only the functionality needed has been implemented in this class.
Properties
protected resource | $resource | ||
protected Type | $type | ||
protected Info | $info | ||
static protected int | $quality | ||
static protected bool | $normalizeJpegOrientation |
Methods
Constructor.
Creates an ImageResource from a file.
Creates an ImageResource from a string of image data.
Creates a new image given the width and height.
Returns the GD resource.
Returns the image dimensions.
Returns the image type.
Returns the image's info.
No description
Allocate a color for an image.
Allocate a transparent color for an image.
Resize part of an image with resampling.
Flips the image.
Rotates the image.
Writes the image to a file.
Returns the image as a data string.
No description
No description
No description
Returns whether JPEG orientation is normalized or not.
Enable or disable JPEG orientation normalization.
Sets the quality setting.
Returns the quality setting.
Convert JPEG quality scale to PNG compression scale.
Convert PNG compression scale to JPEG quality scale.
If orientation in EXIF data is not normal, flip and/or rotate image until it is correct
If image changes, info needs to be recreated
Details
at line 40
__construct(resource $resource, Type $type = null, Info $info = null)
Constructor.
Either type or info need to be provided.
at line 68
static ImageResource
createFromFile(string $file)
Creates an ImageResource from a file.
at line 98
static ImageResource
createFromString(string $data)
Creates an ImageResource from a string of image data.
at line 117
static ImageResource
createNew(Dimensions $dimensions, Type $type)
Creates a new image given the width and height.
at line 136
resource
getResource()
Returns the GD resource.
at line 146
Dimensions
getDimensions()
Returns the image dimensions.
at line 156
Type
getType()
Returns the image type.
at line 166
Info
getInfo()
Returns the image's info.
at line 178
Exif
getExif()
at line 193
Color
allocateColor(int $red, int $green, int $blue, int|null $alpha = null)
Allocate a color for an image.
at line 269
ImageResource
fill(Color $color, Point $startPoint = null)
Flood fill.
at line 289
ImageResource
resample(Point $destPoint, Point $srcPoint, Dimensions $destDimensions, Dimensions $srcDimensions, ImageResource $dest = null)
Resize part of an image with resampling.
at line 326
ImageResource
flip(string $mode)
Flips the image.
Based on http://stackoverflow.com/a/10001884/1136593 Thanks Jon Grant
at line 357
ImageResource
rotate(string $angle)
Rotates the image.
at line 380
toFile(string $file)
Writes the image to a file.
at line 407
string
toString()
Returns the image as a data string.
at line 427
__toString()
at line 439
__clone()
at line 455
__destroy()
at line 465
static boolean
isJpegOrientationNormalized()
Returns whether JPEG orientation is normalized or not.
at line 475
static
setNormalizeJpegOrientation(boolean $normalizeJpegOrientation)
Enable or disable JPEG orientation normalization.
at line 487
static
setQuality(int $quality)
Sets the quality setting.
Note: A quality < 10 is assumed to be PNG compression scale.
at line 507
static int
getQuality()
Returns the quality setting.
at line 520
static protected int
convertJpegQualityToPngCompression(int $quality)
Convert JPEG quality scale to PNG compression scale.
JPEG: 0 (worst) - 100 (best). PNG: 0 (best) - 10 (worst)
at line 535
static protected int
convertPngCompressionToJpegQuality(int $compression)
Convert PNG compression scale to JPEG quality scale.
at line 544
protected
normalizeJpegOrientation()
If orientation in EXIF data is not normal, flip and/or rotate image until it is correct
at line 575
protected
resetInfo()
If image changes, info needs to be recreated