File component
getImageSize($src)
Get the dimensions of an image file, results are cached in the$this->files
array and are indexed by $src
. You can retrieve the values of an image from this array at any future time within the instance. Return is an array on success, Boolean false on failure.getImageFormat($src)
Get the format (gif, jpeg, etc.) of an image file. Return is a string for standard image types, int for non-standard, boolean false on failure.isInvalidUpload($id, $imagesOnly = false)
Checks if an uploaded file has or has not been successfully uploaded and is in the expected format. Returns Boolean false if valid, error message string if invalid.uploadFile($id, $destination, $imagesOnly = false)
Validates and then moves a file that was uploaded from a form. Returns Boolean false on success, an error message string on failure.resizeImage(array $specs, $src = null)
Resizes an image or generates a set of resized images, optionally adding a watermark to any of them.Requires the PHP GD extension to be enabled.
$specs
array keys:width
- required, if constrain is true then this becomes the maximum widthheight
- required, if constrain is true then this becomes the maximum heightconstrain
- (boolean) default is true - resize the image proportionally, if false the end image may be stretchedonlyReduce
- (boolean) default is true - if true the end image can only be reduced, never be enlarged (which usually degrades quality)outputFolder
- folder where to output the file, if omitted the system default will be usedoutputFile
- filename, if omitted the source filename will be usedwatermark
- array with keys:src
- required, the path to the watermark image fileopacity
- Optional, default if omitted is 14
You can also specify generation of multiple output files by setting specs to an array of
$specs
, eg.:$specs[] = array('width' => 200, 'height' => 100, 'outputFile' => 'thumbnail.jpg'); $specs[] = array('width' => 500, 'height' => 300, 'outputFile' => 'bigfile.jpg');
if the
$src
argument is omitted then the last file added to $this->files
will be used, if none exists then this method will exit and return false