$config
$config : \Config\Images
Configuration settings.
Class ImageMagickHandler
To make this library as compatible as possible with the broadest number of installations, we do not use the Imagick extension, but simply use the command line version.
hmm - the width & height accessors at the end use the imagick extension.
FIXME - This needs conversion & unit testing, to use the imagick extension
$config : \Config\Images
Configuration settings.
$image : \CodeIgniter\Images\Image
The image/file instance
getFile() : \CodeIgniter\Images\Image
Returns the image instance.
resize(integer $width, integer $height, boolean $maintainRatio = false, string $masterDim = 'auto') : \CodeIgniter\Images\Handlers\BaseHandler
Resize the image
integer | $width | |
integer | $height | |
boolean | $maintainRatio | If true, will get the closest match possible while keeping aspect ratio true. |
string | $masterDim |
crop(integer|null $width = null, integer|null $height = null, integer|null $x = null, integer|null $y = null, boolean $maintainRatio = false, string $masterDim = 'auto') : mixed
Crops the image to the desired height and width. If one of the height/width values is not provided, that value will be set the appropriate value based on offsets and image dimensions.
integer|null | $width | |
integer|null | $height | |
integer|null | $x | X-axis coord to start cropping from the left of image |
integer|null | $y | Y-axis coord to start cropping from the top of image |
boolean | $maintainRatio | |
string | $masterDim |
convert(integer|null $imageType) : $this
Changes the stored image type to indicate the new file format to use when saving.
Does not touch the actual resource.
integer|null | $imageType | A PHP imageType constant, e.g. https://www.php.net/manual/en/function.image-type-to-mime-type.php |
text(string $text, array $options = array()) : $this
Overlays a string of text over the image.
Valid options:
string | $text | |
array | $options |
reorient(boolean $silent = false) : $this
Reads the EXIF information from the image and modifies the orientation so that displays correctly in the browser. This is especially an issue with images taken by smartphones who always store the image up-right, but set the orientation flag to display it correctly.
boolean | $silent | If true, will ignore exceptions when PHP doesn't support EXIF. |
getEXIF(string|null $key = null, boolean $silent = false) : mixed
Retrieve the EXIF information from the image, if possible. Returns an array of the information, or null if nothing can be found.
EXIF data is only supported fr JPEG & TIFF formats.
string|null | $key | If specified, will only return this piece of EXIF data. |
boolean | $silent | If true, will not throw our own exceptions. |
fit(integer $width, integer $height = null, string $position = 'center') : boolean
Combine cropping and resizing into a single command.
Supported positions:
integer | $width | |
integer | $height | |
string | $position |
save(string|null $target = null, integer $quality = 90) : boolean
Saves any changes that have been made to file. If no new filename is provided, the existing image is overwritten, otherwise a copy of the file is made at $target.
Example: $image->resize(100, 200, true) ->save();
string|null | $target | |
integer | $quality |
_resize(boolean $maintainRatio = false) : \CodeIgniter\Images\Handlers\ImageMagickHandler
Handles the actual resizing of the image.
boolean | $maintainRatio |
_crop() : boolean|\CodeIgniter\Images\Handlers\ImageMagickHandler
Crops the image.
reproportion() : void
Re-proportion Image Width/Height
When creating thumbs, the desired width/height can end up warping the image due to an incorrect ratio between the full-sized image and the thumb.
This function lets us re-proportion the width/height if users choose to maintain the aspect ratio when resizing.
getResourcePath() : resource|boolean
Get Image Resource
This simply creates an image resource handle based on the type of image being processed. Since ImageMagick is used on the cli, we need to ensure we have a temporary file on the server that we can use.
To ensure we can use all features, like transparency, during the process, we'll use a PNG as the temp file type.