-
Notifications
You must be signed in to change notification settings - Fork 12
7.4. Image
Dynamic Image processor
use Cradle\Image\ImageHandler;
$image = ImageHandler::i('/path/to/image.jpg');Once you are done modifying the image you can save the image to a file or simply echo out the image object like below.
header('Content-Type: image/jpg');
echo $image;- blur
- brightness
- colorize
- contrast
- crop
- edgedetect
- emboss
- gaussianBlur
- getDimensions
- getResource
- greyscale
- invert
- meanRemoval
- negative
- resize
- rotate
- scale
- setTransparency
- smooth
- save
Applies the selective blur filter. Blurs the image
$image->blur();Returns Cradle\Image\ImageHandler
Applies the brightness filter. Changes the brightness of the image.
$image->brightness(*number $level);-
*number $level- The level of brightness
Returns Cradle\Image\ImageHandler
$image->brightness($level);Applies the colorize filter. Like greyscale except you can specify the color.
$image->colorize(*number $red, *number $blue, *number $green, number $alpha);-
*number $red- The 255 value of red to use -
*number $blue- The 255 value of blue to use -
*number $green- The 255 value of green to use -
number $alpha- The level of alpha transparency
Returns Cradle\Image\ImageHandler
$image->colorize($red, $blue, $green);Applies the contrast filter. Changes the contrast of the image.
$image->contrast(*number $level);-
*number $level- The level of contrast
Returns Cradle\Image\ImageHandler
$image->contrast($level);Crops the image
$image->crop(int|null $width, int|null $height);-
int|null $width- The width; If null will use the original width -
int|null $height- The height; If null will use the original height
Returns Cradle\Image\ImageHandler
$image->crop();Applies the edgedetect filter. Uses edge detection to highlight the edges in the image.
$image->edgedetect();Returns Cradle\Image\ImageHandler
Applies the emboss filter. Embosses the image.
$image->emboss();Returns Cradle\Image\ImageHandler
Applies the gaussian blur filter. Blurs the image using the Gaussian method.
$image->gaussianBlur();Returns Cradle\Image\ImageHandler
Returns the size of the image
$image->getDimensions();Returns array
Returns the resource for custom editing
$image->getResource();Returns [RESOURCE]
Applies the greyscale filter. Converts the image into grayscale.
$image->greyscale();Returns Cradle\Image\ImageHandler
Inverts the image.
$image->invert(bool $vertical);-
bool $vertical- If true invert vertical; if false invert horizontal
Returns Cradle\Image\ImageHandler
$image->invert();Applies the mean removal filter. Uses mean removal to achieve a "sketchy" effect.
$image->meanRemoval();Returns Cradle\Image\ImageHandler
Applies the greyscale filter. Reverses all colors of the image.
$image->negative();Returns Cradle\Image\ImageHandler
Resizes the image. This is a version of scale but keeping it's original aspect ratio
$image->resize(int|null $width, int|null $height);-
int|null $width- the width; if null will use the original width -
int|null $height- the height; if null will use the original height
Returns Cradle\Image\ImageHandler
$image->resize();Rotates the image.
$image->rotate(*int $degree, int $background);-
*int $degree- The degree to rotate by -
int $background- Background color code
Returns Cradle\Image\ImageHandler
$image->rotate(123);Scales the image. If width or height is set to null a width or height will be auto determined based on the aspect ratio
$image->scale(int|null $width, int|null $height);-
int|null $width- The width; if null will use the original width -
int|null $height- The height; if null will use the original height
Returns Cradle\Image\ImageHandler
$image->scale();Sets the background color to be transparent
$image->setTransparency();Returns Cradle\Image\ImageHandler
Applies the smooth filter. Makes the image smoother.
$image->smooth(*number $level);-
*number $level- The level of smoothness
Returns Cradle\Image\ImageHandler
$image->smooth($level);Saves the image data to a file
$image->save(*string $path, string|null $type);-
*string $path- The path to save to -
string|null $type- The render type
Returns Cradle\Image\ImageHandler
$image->save('foo');2.B. Reference: Validation Types
2.D. Reference: Indexes & Relations
3.A. Reference: Cradle on Shared Hosts
3.B. Reference: Command Line Tools
3.C. Reference: Architecture Recommendations
4.4. Intro to Handlebars Templating
4.B. Reference: Handlebars Helpers
4.C. Reference: Doon Interfaces
4.D. Reference: Global Package Methods