### Install SimpleImage with Composer Source: https://github.com/claviska/simpleimage/blob/master/README.md Install the SimpleImage library using Composer. ```bash composer require claviska/simpleimage ``` -------------------------------- ### Get image data as string Source: https://github.com/claviska/simpleimage/blob/master/README.md Example of obtaining raw image data as a string, used with the fromString loader. ```php $string = file_get_contents('image.jpg'); ``` -------------------------------- ### Set instance flags via constructor Source: https://github.com/claviska/simpleimage/blob/master/README.md Pass an associative array to the constructor to set instance flags. The second example uses named arguments. ```php $image = new \claviska\SimpleImage('image.jpeg', ['foo' => 'bar']); // .. or without an $image $image = new \claviska\SimpleImage(flags: ['foo' => 'bar']); ``` -------------------------------- ### Check specific error code with ERR_FILE_NOT_FOUND Source: https://github.com/claviska/simpleimage/blob/master/README.md Check for specific errors by comparing $err->getCode() to defined error constants. This example handles ERR_FILE_NOT_FOUND specifically. ```php getCode() === $image::ERR_FILE_NOT_FOUND) { echo 'File not found!'; } else { echo $err->getMessage(); } } ``` -------------------------------- ### getExif() Source: https://github.com/claviska/simpleimage/blob/master/README.md Gets the image's exif data. ```APIDOC ## `getExif()` ### Description Gets the image's exif data. ### Method `getExif` ### Parameters None. ### Returns Array of exif data or null if no data is available. ``` -------------------------------- ### getWidth() Source: https://github.com/claviska/simpleimage/blob/master/README.md Gets the image's current width. ```APIDOC ## `getWidth()` ### Description Gets the image's current width. ### Method `getWidth` ### Parameters None. ### Returns Integer - The width. ``` -------------------------------- ### getHeight() Source: https://github.com/claviska/simpleimage/blob/master/README.md Gets the image's current height. ```APIDOC ## `getHeight()` ### Description Gets the image's current height. ### Method `getHeight` ### Parameters None. ### Returns Integer - The height. ``` -------------------------------- ### arc($x, $y, $width, $height, $start, $end, $color, $thickness) Source: https://github.com/claviska/simpleimage/blob/master/README.md Draws an arc on the image. ```APIDOC ## arc($x, $y, $width, $height, $start, $end, $color, $thickness) ### Description Draws an arc. ### Method arc ### Parameters - **$x** (int) - Required - The x coordinate of the arc's center. - **$y** (int) - Required - The y coordinate of the arc's center. - **$width** (int) - Required - The width of the arc. - **$height** (int) - Required - The height of the arc. - **$start** (int) - Required - The start of the arc in degrees. - **$end** (int) - Required - The end of the arc in degrees. - **$color** (string|array) - Required - The arc color. - **$thickness** (int|string) - Optional - Line thickness in pixels or 'filled' (default 1). ### Returns SimpleImage object. ``` -------------------------------- ### getAspectRatio() Source: https://github.com/claviska/simpleimage/blob/master/README.md Gets the image's current aspect ratio. ```APIDOC ## `getAspectRatio()` ### Description Gets the image's current aspect ratio. ### Method `getAspectRatio` ### Parameters None. ### Returns Float - The aspect ratio. ``` -------------------------------- ### getResolution() Source: https://github.com/claviska/simpleimage/blob/master/README.md Gets the image's current resolution in DPI. ```APIDOC ## `getResolution()` ### Description Gets the image's current resolution in DPI. ### Method `getResolution` ### Parameters None. ### Returns Array of integers: [0 => 96, 1 => 96] ``` -------------------------------- ### getMimeType() Source: https://github.com/claviska/simpleimage/blob/master/README.md Gets the mime type of the loaded image. ```APIDOC ## `getMimeType()` ### Description Gets the mime type of the loaded image. ### Method `getMimeType` ### Parameters None. ### Returns String - Mime type. ``` -------------------------------- ### getOrientation() Source: https://github.com/claviska/simpleimage/blob/master/README.md Gets the image's current orientation. ```APIDOC ## `getOrientation()` ### Description Gets the image's current orientation. ### Method `getOrientation` ### Parameters None. ### Returns String - 'landscape', 'portrait', or 'square'. ``` -------------------------------- ### getColorAt($x, $y) Source: https://github.com/claviska/simpleimage/blob/master/README.md Gets the RGBA value of a single pixel. ```APIDOC ## getColorAt($x, $y) ### Description Gets the RGBA value of a single pixel. ### Method getColorAt ### Parameters - **$x** (int) - Required - The horizontal position of the pixel. - **$y** (int) - Required - The vertical position of the pixel. ### Returns RGBA color array or false if the x/y position is off the canvas. ``` -------------------------------- ### WebP options for toFile() Source: https://github.com/claviska/simpleimage/blob/master/README.md Shows how to pass an options array to toFile() for WebP output, setting the quality option which defaults to 100. ```php $image->toFile($file, 'image/webp', [ // JPG, WEBP, AVIF (default 100) 'quality' => 100, ]); ``` -------------------------------- ### BMP options for toFile() Source: https://github.com/claviska/simpleimage/blob/master/README.md Shows how to pass an options array to toFile() for BMP output, setting compression and interlace. Compression defaults to true, interlace defaults to null (keep the same). ```php $image->toFile($file, 'image/bmp', [ // BMP: boolean (default true) 'compression' => true, // BMP, JPG (default null, keep the same) 'interlace' => null, ]); ``` -------------------------------- ### toScreen($mimeType, $options) Source: https://github.com/claviska/simpleimage/blob/master/README.md Outputs the image to the screen. Must be called before any output is sent to the screen. ```APIDOC ## `toScreen($mimeType, $options)` ### Description Outputs the image to the screen. Must be called before any output is sent to the screen. ### Method `toScreen` ### Parameters - `$mimeType` (string) - Optional - The image format to output as a mime type (defaults to the original mime type). - `$options` (array|int) - Optional - Array of options or Image quality as a percentage (default 100). ### Returns SimpleImage object. ``` -------------------------------- ### PNG options for toFile() Source: https://github.com/claviska/simpleimage/blob/master/README.md Shows how to pass an options array to toFile() for PNG output, setting alpha, compression, and filters. Compression defaults to 6 (zlib), filters default to -1. The quality option has no effect on PNG because it is lossless. ```php $image->toFile($file, 'image/png', [ // GIF, PNG (default true) 'alpha' => true, // PNG: 0-10, defaults to zlib (default 6) 'compression' => -1, // PNG (default -1) 'filters' => -1, // has no effect on PNG images, since the format is lossless // 'quality' => 100, ]); ``` -------------------------------- ### AVIF options for toFile() Source: https://github.com/claviska/simpleimage/blob/master/README.md Shows how to pass an options array to toFile() for AVIF output, setting quality and speed. The speed option defaults to -1 (which is 6) and ranges from 0 (slow, small file) to 10 (fast, big file). ```php $image->toFile($file, 'image/avif', [ // JPG, WEBP, AVIF (default 100) 'quality' => 100, // AVIF (default -1 which is 6) // range of slow and small file 0 to 10 fast but big file 'speed' => -1, ]); ``` -------------------------------- ### overlay($overlay, $anchor, $opacity, $xOffset, $yOffset) Source: https://github.com/claviska/simpleimage/blob/master/README.md Places an image on top of the current image. ```APIDOC ## overlay($overlay, $anchor, $opacity, $xOffset, $yOffset) ### Description Place an image on top of the current image. ### Method overlay ### Parameters - $overlay (string|SimpleImage) - The image to overlay. This can be a filename, a data URI, or a SimpleImage object. - $anchor (string) - The anchor point: 'center', 'top', 'bottom', 'left', 'right', 'top left', 'top right', 'bottom left', 'bottom right' (default 'center') - $opacity (float) - The opacity level of the overlay 0-1 (default 1). - $xOffset (int) - Horizontal offset in pixels (default 0). - $yOffset (int) - Vertical offset in pixels (default 0). - $calculateOffsetFromEdge (bool) - Calculate Offset referring to the edges of the image. $xOffset and $yOffset have no effect in center anchor. (default false). ### Returns SimpleImage object. ``` -------------------------------- ### toDownload($filename, $mimeType, $options) Source: https://github.com/claviska/simpleimage/blob/master/README.md Forces the image to be downloaded to the client's machine. Must be called before any output is sent to the screen. ```APIDOC ## `toDownload($filename, $mimeType, $options)` ### Description Forces the image to be downloaded to the client's machine. Must be called before any output is sent to the screen. ### Method `toDownload` ### Parameters - `$filename`* (string) - Required - The filename (without path) to send to the client (e.g. 'image.jpeg'). - `$mimeType` (string) - Optional - The image format to output as a mime type (defaults to the original mime type). - `$options` (array|int) - Optional - Array of options or Image quality as a percentage (default 100). ### Returns SimpleImage object. ``` -------------------------------- ### JPEG options for toFile() Source: https://github.com/claviska/simpleimage/blob/master/README.md Shows how to pass an options array to toFile() for JPEG output, setting interlace and quality. Interlace defaults to null (keep the same), quality defaults to 100. ```php $image->toFile($file, 'image/jpeg', [ // BMP, JPG (default null, keep the same) 'interlace' => null, // JPG, WEBP, AVIF (default 100) 'quality' => 100, ]); ``` -------------------------------- ### Set instance flag with setFlag() Source: https://github.com/claviska/simpleimage/blob/master/README.md Set an instance flag using the setFlag() method. Throws ERR_INVALID_FLAG if the key does not exist. ```php $image = new \claviska\SimpleImage('image.jpeg')->setFlag("foo", "bar"); ``` -------------------------------- ### thumbnail($width, $height, $anchor) Source: https://github.com/claviska/simpleimage/blob/master/README.md Creates a thumbnail image. ```APIDOC ## thumbnail($width, $height, $anchor) ### Description Creates a thumbnail image. This function attempts to get the image as close to the provided dimensions as possible, then crops the remaining overflow to force the desired size. Useful for generating thumbnail images. ### Method thumbnail ### Parameters - $width (int) - The thumbnail width. - $height (int) - The thumbnail height. - $anchor (string) - The anchor point: 'center', 'top', 'bottom', 'left', 'right', 'top left', 'top right', 'bottom left', 'bottom right' (default 'center'). ### Returns SimpleImage object. ``` -------------------------------- ### GIF options for toFile() Source: https://github.com/claviska/simpleimage/blob/master/README.md Shows how to pass an options array to toFile() for GIF output, setting the alpha option which defaults to true. ```php $image->toFile($file, 'image/gif', [ // GIF, PNG (default true) 'alpha' => true, ]); ``` -------------------------------- ### Include SimpleImage manually Source: https://github.com/claviska/simpleimage/blob/master/README.md Include the SimpleImage library manually by requiring the main file. ```php getMessage(); } ``` -------------------------------- ### SimpleImage basic usage with chained methods Source: https://github.com/claviska/simpleimage/blob/master/README.md Basic usage of the SimpleImage class: load an image, apply transformations (auto-orient, resize, flip, colorize, border, overlay), save a copy, and output to screen. Wrap in try/catch to handle exceptions. ```php fromFile('image.jpg') // load image.jpg ->autoOrient() // adjust orientation based on exif data ->resize(320, 200) // resize to 320x200 pixels ->flip('x') // flip horizontally ->colorize('DarkBlue') // tint dark blue ->border('black', 10) // add a 10 pixel black border ->overlay('watermark.png', 'bottom right') // add a watermark image ->toFile('new-image.png', 'image/png') // convert to PNG and save a copy to new-image.png ->toScreen(); // output to the screen // And much more! 💪 } catch(Exception $err) { // Handle errors echo $err->getMessage(); } ``` -------------------------------- ### bestFit($maxWidth, $maxHeight) Source: https://github.com/claviska/simpleimage/blob/master/README.md Proportionally resize the image to fit inside a specific width and height. ```APIDOC ## `bestFit($maxWidth, $maxHeight)` ### Description Proportionally resize the image to fit inside a specific width and height. ### Method `bestFit` ### Parameters - `$maxWidth`* (int) - Required - The maximum width the image can be. - `$maxHeight`* (int) - Required - The maximum height the image can be. ### Returns SimpleImage object. ``` -------------------------------- ### contrast($percentage) Source: https://github.com/claviska/simpleimage/blob/master/README.md Applies the contrast filter to the image. ```APIDOC ## contrast($percentage) ### Description Applies the contrast filter to the image. ### Method contrast ### Parameters - **$percentage** (int) - Required - Percentage to adjust (-100 - 100). ### Returns SimpleImage object. ``` -------------------------------- ### toString($mimeType, $options) Source: https://github.com/claviska/simpleimage/blob/master/README.md Generates an image string. ```APIDOC ## `toString($mimeType, $options)` ### Description Generates an image string. ### Method `toString` ### Parameters - `$mimeType` (string) - Optional - The image format to output as a mime type (defaults to the original mime type). - `$options` (array|int) - Optional - Array of options or Image quality as a percentage (default 100). ### Returns SimpleImage object. ``` -------------------------------- ### toFile($file, $mimeType, $options) Source: https://github.com/claviska/simpleimage/blob/master/README.md Writes the image to a file. ```APIDOC ## `toFile($file, $mimeType, $options)` ### Description Writes the image to a file. ### Method `toFile` ### Parameters - `$file` (string) - Required - The file path to write to. - `$mimeType` (string) - Optional - The image format to output as a mime type (defaults to the original mime type). - `$options` (array|int) - Optional - Array of options or Image quality as a percentage (default 100). ### Returns SimpleImage object. ``` -------------------------------- ### Options array Source: https://github.com/claviska/simpleimage/blob/master/README.md Options array for various mime types. ```APIDOC ## Options array ### Description Instead of providing the quality as an integer as the last function parameter you can also set various options depending on the targeted Mime type using an associative array. ### Options by Mime Type #### image/avif - `quality` (int) - Optional - Default 100. - `speed` (int) - Optional - Default -1 (which is 6). Range of slow and small file 0 to 10 fast but big file. #### image/bmp - `compression` (bool) - Optional - Default true. - `interlace` (mixed) - Optional - Default null, keep the same. #### image/gif - `alpha` (bool) - Optional - Default true. #### image/jpeg - `interlace` (mixed) - Optional - Default null, keep the same. - `quality` (int) - Optional - Default 100. #### image/png - `alpha` (bool) - Optional - Default true. - `compression` (int) - Optional - Default -1 (which is 6). 0-10, defaults to zlib. - `filters` (int) - Optional - Default -1. - `quality` (int) - Optional - Has no effect on PNG images, since the format is lossless. #### image/webp - `quality` (int) - Optional - Default 100. ``` -------------------------------- ### generate($mimeType, $options) Source: https://github.com/claviska/simpleimage/blob/master/README.md Generates an image. ```APIDOC ## `generate($mimeType, $options)` ### Description Generates an image. ### Method `generate` ### Parameters - `$mimeType` (string) - Optional - The image format to output as a mime type (defaults to the original mime type). - `$options` (array|int) - Optional - Array of options or Image quality as a percentage (default 100). ### Returns Array: [mimeType, data] ``` -------------------------------- ### fill($color) Source: https://github.com/claviska/simpleimage/blob/master/README.md Fills the image with a solid color. ```APIDOC ## fill($color) ### Description Fills the image with a solid color. ### Method fill ### Parameters - **$color** (string|array) - Required - The fill color. ### Returns SimpleImage object. ``` -------------------------------- ### fitToHeight($height) Source: https://github.com/claviska/simpleimage/blob/master/README.md Proportionally resizes the image to a specific height. Deprecated, use resize(null, $height) instead. ```APIDOC ## fitToHeight($height) (DEPRECATED) ### Description Proportionally resize the image to a specific height. Deprecated in version 3.2.2, use resize(null, $height) instead. ### Method fitToHeight ### Parameters - $height (int) - The height to resize the image to. ### Returns SimpleImage object. ``` -------------------------------- ### extractColors($count = 10, $backgroundColor = null) Source: https://github.com/claviska/simpleimage/blob/master/README.md Extracts colors from an image like a human would do. ```APIDOC ## extractColors($count = 10, $backgroundColor = null) ### Description Extracts colors from an image like a human would do. This method requires the third-party library \League\ColorExtractor. If you're using Composer, it will be installed for you automatically. ### Method extractColors ### Parameters - **$count** (int) - Optional - The max number of colors to extract (default 5). - **$backgroundColor** (string|array) - Optional - By default any pixel with alpha value greater than zero will be discarded. This is because transparent colors are not perceived as is. For example, fully transparent black would be seen white on a white background. So if you want to take transparency into account, you have to specify a default background color. ### Returns Array of RGBA colors arrays. ``` -------------------------------- ### resize($width, $height) Source: https://github.com/claviska/simpleimage/blob/master/README.md Resizes the image to the specified dimensions. ```APIDOC ## resize($width, $height) ### Description Resize an image to the specified dimensions. If only one dimension is specified, the image will be resized proportionally. ### Method resize ### Parameters - $width (int) - The new image width. - $height (int) - The new image height. ### Returns SimpleImage object. ``` -------------------------------- ### text($text, $options, &$boundary) Source: https://github.com/claviska/simpleimage/blob/master/README.md Adds text to the image. ```APIDOC ## text($text, $options, &$boundary) ### Description Adds text to the image. ### Method text ### Parameters - $text (string) - The desired text. - $options (array) - An array of options. - fontFile (string) - The TrueType (or compatible) font file to use. - size (int) - The size of the font in pixels (default 12). - color (string|array) - The text color (default black). - anchor (string) - The anchor point: 'center', 'top', 'bottom', 'left', 'right', 'top left', 'top right', 'bottom left', 'bottom right' (default 'center'). - xOffset (int) - The horizontal offset in pixels (default 0). - yOffset (int) - The vertical offset in pixels (default 0). - shadow (array) - Text shadow params. - x (int) - Horizontal offset in pixels. - y (int) - Vertical offset in pixels. - color (string|array) - The text shadow color. - calculateOffsetFromEdge (bool) - Calculate Offset referring to the edges of the image (default false). - baselineAlign (bool) - Align the text font with the baseline. (default true). - $boundary (array) - If passed, this variable will contain an array with coordinates that surround the text: [x1, y1, x2, y2, width, height]. This can be used for calculating the text's position after it gets added to the image. ### Returns SimpleImage object. ``` -------------------------------- ### sepia() Source: https://github.com/claviska/simpleimage/blob/master/README.md Simulates a sepia effect by desaturating the image and applying a sepia tone. ```APIDOC ## sepia() ### Description Simulates a sepia effect by desaturating the image and applying a sepia tone. ### Method sepia ### Parameters None. ### Returns SimpleImage object. ``` -------------------------------- ### polygon($vertices, $color, $thickness) Source: https://github.com/claviska/simpleimage/blob/master/README.md Draws a polygon. ```APIDOC ## polygon($vertices, $color, $thickness) ### Description Draws a polygon. ### Method polygon ### Parameters - **$vertices** (array) - Required - The polygon's vertices in an array of x/y arrays. Example: [['x' => x1, 'y' => y1], ['x' => x2, 'y' => y2], ['x' => xN, 'y' => yN]] - **$color** (string|array) - Required - The polygon color. - **$thickness** (int|string) - Optional - Line thickness in pixels or 'filled' (default 1). ### Returns SimpleImage object. ``` -------------------------------- ### fitToWidth($width) Source: https://github.com/claviska/simpleimage/blob/master/README.md Proportionally resizes the image to a specific width. Deprecated, use resize($width, null) instead. ```APIDOC ## fitToWidth($width) (DEPRECATED) ### Description Proportionally resize the image to a specific width. Deprecated in version 3.2.2, use resize($width, null) instead. ### Method fitToWidth ### Parameters - $width (int) - The width to resize the image to. ### Returns SimpleImage object. ``` -------------------------------- ### border($color, $thickness) Source: https://github.com/claviska/simpleimage/blob/master/README.md Draws a border around the image. ```APIDOC ## border($color, $thickness) ### Description Draws a border around the image. ### Method border ### Parameters - **$color** (string|array) - Required - The border color. - **$thickness** (int) - Optional - The thickness of the border (default 1). ### Returns SimpleImage object. ``` -------------------------------- ### sharpen($amount) Source: https://github.com/claviska/simpleimage/blob/master/README.md Sharpens the image. ```APIDOC ## sharpen($amount) ### Description Sharpens the image. ### Method sharpen ### Parameters - **$amount** (int) - Optional - Sharpening amount (1 - 100, default 50). ### Returns SimpleImage object. ``` -------------------------------- ### toDataUri($mimeType, $options) Source: https://github.com/claviska/simpleimage/blob/master/README.md Generates a data URI for the image. ```APIDOC ## `toDataUri($mimeType, $options)` ### Description Generates a data URI for the image. ### Method `toDataUri` ### Parameters - `$mimeType` (string) - Optional - The image format to output as a mime type (defaults to the original mime type). - `$options` (array|int) - Optional - Array of options or Image quality as a percentage (default 100). ### Returns String containing a data URI. ``` -------------------------------- ### maxColors($max, $dither) Source: https://github.com/claviska/simpleimage/blob/master/README.md Reduces the image to a maximum number of colors. ```APIDOC ## maxColors($max, $dither) ### Description Reduces the image to a maximum number of colors. ### Method maxColors ### Parameters - $max (int) - The maximum number of colors to use. - $dither (bool) - Whether or not to use a dithering effect (default true). ### Returns SimpleImage object. ``` -------------------------------- ### line($x1, $y1, $x2, $y2, $color, $thickness) Source: https://github.com/claviska/simpleimage/blob/master/README.md Draws a line. ```APIDOC ## line($x1, $y1, $x2, $y2, $color, $thickness) ### Description Draws a line. ### Method line ### Parameters - **$x1** (int) - Required - The x coordinate for the first point. - **$y1** (int) - Required - The y coordinate for the first point. - **$x2** (int) - Required - The x coordinate for the second point. - **$y2** (int) - Required - The y coordinate for the second point. - **$color** (string|array) - Required - The line color. - **$thickness** (int) - Optional - The line thickness (default 1). ### Returns SimpleImage object. ``` -------------------------------- ### opacity($opacity) Source: https://github.com/claviska/simpleimage/blob/master/README.md Changes the image's opacity level. ```APIDOC ## opacity($opacity) ### Description Changes the image's opacity level. ### Method opacity ### Parameters - **$opacity** (float) - Required - The desired opacity level (0 - 1). ### Returns SimpleImage object. ``` -------------------------------- ### (static) lightenColor($color, $amount) Source: https://github.com/claviska/simpleimage/blob/master/README.md Lightens a color. ```APIDOC ## (static) lightenColor($color, $amount) ### Description Lightens a color. ### Method lightenColor ### Parameters - **$color** (string|array) - Required - The color to lighten. - **$amount** (int) - Required - Amount to darken (0 - 255). ### Returns RGBA color array. ``` -------------------------------- ### duotone($lightColor, $darkColor) Source: https://github.com/claviska/simpleimage/blob/master/README.md Applies the duotone filter to the image. ```APIDOC ## duotone($lightColor, $darkColor) ### Description Applies the duotone filter to the image. ### Method duotone ### Parameters - **$lightColor** (string|array) - Required - The lightest color in the duotone. - **$darkColor** (string|array) - Required - The darkest color in the duotone. ### Returns SimpleImage object. ``` -------------------------------- ### rectangle($x1, $y1, $x2, $y2, $color, $thickness) Source: https://github.com/claviska/simpleimage/blob/master/README.md Draws a rectangle. ```APIDOC ## rectangle($x1, $y1, $x2, $y2, $color, $thickness) ### Description Draws a rectangle. ### Method rectangle ### Parameters - **$x1** (int) - Required - The upper left x coordinate. - **$y1** (int) - Required - The upper left y coordinate. - **$x2** (int) - Required - The bottom right x coordinate. - **$y2** (int) - Required - The bottom right y coordinate. - **$color** (string|array) - Required - The rectangle color. - **$thickness** (int|string) - Optional - Line thickness in pixels or 'filled' (default 1). ### Returns SimpleImage object. ``` -------------------------------- ### ellipse($x, $y, $width, $height, $color, $thickness) Source: https://github.com/claviska/simpleimage/blob/master/README.md Draws an ellipse. ```APIDOC ## ellipse($x, $y, $width, $height, $color, $thickness) ### Description Draws an ellipse. ### Method ellipse ### Parameters - **$x** (int) - Required - The x coordinate of the center. - **$y** (int) - Required - The y coordinate of the center. - **$width** (int) - Required - The ellipse width. - **$height** (int) - Required - The ellipse height. - **$color** (string|array) - Required - The ellipse color. - **$thickness** (int|string) - Optional - Line thickness in pixels or 'filled' (default 1). ### Returns SimpleImage object. ``` -------------------------------- ### colorize($color) Source: https://github.com/claviska/simpleimage/blob/master/README.md Applies the colorize filter to the image. ```APIDOC ## colorize($color) ### Description Applies the colorize filter to the image. ### Method colorize ### Parameters - **$color** (string|array) - Required - The filter color. ### Returns SimpleImage object. ``` -------------------------------- ### brighten($percentage) Source: https://github.com/claviska/simpleimage/blob/master/README.md Applies the brightness filter to brighten the image. ```APIDOC ## brighten($percentage) ### Description Applies the brightness filter to brighten the image. ### Method brighten ### Parameters - **$percentage** (int) - Required - Percentage to brighten the image (0 - 100). ### Returns SimpleImage object. ``` -------------------------------- ### (static) adjustColor($color, $red, $green, $blue, $alpha) Source: https://github.com/claviska/simpleimage/blob/master/README.md Adjusts a color by increasing/decreasing red/green/blue/alpha values independently. ```APIDOC ## (static) adjustColor($color, $red, $green, $blue, $alpha) ### Description Adjusts a color by increasing/decreasing red/green/blue/alpha values independently. ### Method adjustColor ### Parameters - **$color** (string|array) - Required - The color to adjust. - **$red** (int) - Required - Red adjustment (-255 - 255). - **$green** (int) - Required - Green adjustment (-255 - 255). - **$blue** (int) - Required - Blue adjustment (-255 - 255). - **$alpha** (float) - Required - Alpha adjustment (-1 - 1). ### Returns RGBA color array. ``` -------------------------------- ### crop($x1, $y1, $x2, $y2) Source: https://github.com/claviska/simpleimage/blob/master/README.md Crops the image to the specified coordinates. ```APIDOC ## crop($x1, $y1, $x2, $y2) ### Description Crop the image. ### Method crop ### Parameters - $x1 (int) - Top left x coordinate. - $y1 (int) - Top left y coordinate. - $x2 (int) - Bottom right x coordinate. - $y2 (int) - Bottom right y coordinate. ### Returns SimpleImage object. ``` -------------------------------- ### flip($direction) Source: https://github.com/claviska/simpleimage/blob/master/README.md Flips the image horizontally or vertically. ```APIDOC ## flip($direction) ### Description Flip the image horizontally or vertically. ### Method flip ### Parameters - $direction (string) - The direction to flip: x|y|both ### Returns SimpleImage object. ``` -------------------------------- ### rotate($angle, $backgroundColor) Source: https://github.com/claviska/simpleimage/blob/master/README.md Rotates the image. ```APIDOC ## rotate($angle, $backgroundColor) ### Description Rotates the image. ### Method rotate ### Parameters - $angle (int) - The angle of rotation (-360 - 360). - $backgroundColor (string|array) - The background color to use for the uncovered zone area after rotation (default 'transparent'). ### Returns SimpleImage object. ``` -------------------------------- ### hasImage() Source: https://github.com/claviska/simpleimage/blob/master/README.md Checks if the SimpleImage object has loaded an image. ```APIDOC ## `hasImage()` ### Description Checks if the SimpleImage object has loaded an image. ### Method `hasImage` ### Parameters None. ### Returns Boolean. ``` -------------------------------- ### resolution($res_x, $res_y) Source: https://github.com/claviska/simpleimage/blob/master/README.md Changes the resolution (DPI) of an image. ```APIDOC ## resolution($res_x, $res_y) ### Description Changes the resolution (DPI) of an image. ### Method resolution ### Parameters - $res_x (int) - The horizontal resolution, in DPI. - $res_y (int) - The vertical resolution, in DPI. ### Returns SimpleImage object. ``` -------------------------------- ### invert() Source: https://github.com/claviska/simpleimage/blob/master/README.md Inverts the image's colors. ```APIDOC ## invert() ### Description Inverts the image's colors. ### Method invert ### Parameters None. ### Returns SimpleImage object. ``` -------------------------------- ### emboss() Source: https://github.com/claviska/simpleimage/blob/master/README.md Applies the emboss filter to the image. ```APIDOC ## emboss() ### Description Applies the emboss filter to the image. ### Method emboss ### Parameters None. ### Returns SimpleImage object. ``` -------------------------------- ### darken($percentage) Source: https://github.com/claviska/simpleimage/blob/master/README.md Applies the brightness filter to darken the image. ```APIDOC ## darken($percentage) ### Description Applies the brightness filter to darken the image. ### Method darken ### Parameters - **$percentage** (int) - Required - Percentage to darken the image (0 - 100). ### Returns SimpleImage object. ``` -------------------------------- ### (static) darkenColor($color, $amount) Source: https://github.com/claviska/simpleimage/blob/master/README.md Darkens a color. ```APIDOC ## (static) darkenColor($color, $amount) ### Description Darkens a color. ### Method darkenColor ### Parameters - **$color** (string|array) - Required - The color to darken. - **$amount** (int) - Required - Amount to darken (0 - 255). ### Returns RGBA color array. ``` -------------------------------- ### desaturate() Source: https://github.com/claviska/simpleimage/blob/master/README.md Applies the desaturate (grayscale) filter to the image. ```APIDOC ## desaturate() ### Description Applies the desaturate (grayscale) filter to the image. ### Method desaturate ### Parameters None. ### Returns SimpleImage object. ``` -------------------------------- ### dot($x, $y, $color) Source: https://github.com/claviska/simpleimage/blob/master/README.md Draws a single pixel dot. ```APIDOC ## dot($x, $y, $color) ### Description Draws a single pixel dot. ### Method dot ### Parameters - **$x** (int) - Required - The x coordinate of the dot. - **$y** (int) - Required - The y coordinate of the dot. - **$color** (string|array) - Required - The dot color. ### Returns SimpleImage object. ``` -------------------------------- ### (static) normalizeColor($color) Source: https://github.com/claviska/simpleimage/blob/master/README.md Normalizes a hex or array color value to a well-formatted RGBA array. ```APIDOC ## (static) normalizeColor($color) ### Description Normalizes a hex or array color value to a well-formatted RGBA array. ### Method normalizeColor ### Parameters - **$color** (string|array) - Required - A CSS color name, hex string, or an array [red, green, blue, alpha]. You can pipe alpha transparency through hex strings and color names. For example: #fff|0.50 <-- 50% white red|0.25 <-- 25% red ### Returns Array: [red, green, blue, alpha]. ``` -------------------------------- ### reset() Source: https://github.com/claviska/simpleimage/blob/master/README.md Destroys the image resource. Deprecated in SimpleImage 4.4.0. ```APIDOC ## `reset()` ### Description Destroys the image resource. Note: The `reset()` method has been deprecated in SimpleImage 4.4.0. Calling the method has no effect. ### Method `reset` ### Parameters None. ### Returns SimpleImage object. ``` -------------------------------- ### autoOrient() Source: https://github.com/claviska/simpleimage/blob/master/README.md Rotates an image so the orientation will be correct based on its exif data. ```APIDOC ## `autoOrient()` ### Description Rotates an image so the orientation will be correct based on its exif data. It is safe to call this method on images that don't have exif data (no changes will be made). ### Method `autoOrient` ### Parameters None. ### Returns SimpleImage object. ``` -------------------------------- ### sketch() Source: https://github.com/claviska/simpleimage/blob/master/README.md Applies the mean remove filter to produce a sketch effect. ```APIDOC ## sketch() ### Description Applies the mean remove filter to produce a sketch effect. ### Method sketch ### Parameters None. ### Returns SimpleImage object. ``` -------------------------------- ### edgeDetect() Source: https://github.com/claviska/simpleimage/blob/master/README.md Applies the edge detect filter to the image. ```APIDOC ## edgeDetect() ### Description Applies the edge detect filter to the image. ### Method edgeDetect ### Parameters None. ### Returns SimpleImage object. ``` -------------------------------- ### roundedRectangle($x1, $y1, $x2, $y2, $radius, $color, $thickness) Source: https://github.com/claviska/simpleimage/blob/master/README.md Draws a rounded rectangle. ```APIDOC ## roundedRectangle($x1, $y1, $x2, $y2, $radius, $color, $thickness) ### Description Draws a rounded rectangle. ### Method roundedRectangle ### Parameters - **$x1** (int) - Required - The upper left x coordinate. - **$y1** (int) - Required - The upper left y coordinate. - **$x2** (int) - Required - The bottom right x coordinate. - **$y2** (int) - Required - The bottom right y coordinate. - **$radius** (int) - Required - The border radius in pixels. - **$color** (string|array) - Required - The rectangle color. - **$thickness** (int|string) - Optional - Line thickness in pixels or 'filled' (default 1). ### Returns SimpleImage object. ``` -------------------------------- ### pixelate($size) Source: https://github.com/claviska/simpleimage/blob/master/README.md Applies the pixelate filter to the image. ```APIDOC ## pixelate($size) ### Description Applies the pixelate filter to the image. ### Method pixelate ### Parameters - **$size** (int) - Optional - The size of the blocks in pixels (default 10). ### Returns SimpleImage object. ``` -------------------------------- ### blur($type, $passes) Source: https://github.com/claviska/simpleimage/blob/master/README.md Applies the blur filter to the image. ```APIDOC ## blur($type, $passes) ### Description Applies the blur filter to the image. ### Method blur ### Parameters - **$type** (string) - Optional - The blur algorithm to use: 'selective', 'gaussian' (default 'gaussian'). - **$passes** (int) - Optional - The number of times to apply the filter, enhancing the effect (default 1). ### Returns SimpleImage object. ``` -------------------------------- ### Disable SSL verification with sslVerify flag Source: https://github.com/claviska/simpleimage/blob/master/README.md Set sslVerify to false to skip certificate peer validation for HTTPS images. Useful for self-signed certificates. ```php $image = new \claviska\SimpleImage('https://localhost/image.jpeg', ['sslVerify' => false]); // Would normally throw an OpenSSL exception, but is ignored with the sslVerify flag set to false. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.