Image manipulation utils
package |
Default |
---|
compressJpgPicture(string $imagePath, string $outputPath = '') : boolean
jpegtran is an open source library tool to compress jpg images as much as possible, that normally comes bundled with linux distributions. If not available, we must install it on our machine.
string
Full file system path to the image file we want to compress
string
Leave it empty (default value) to override the source image or specify a full system path (including the destination filename) where the compressed image will be stored. Warning: Do not set the output path to the same value as the source path or an error will happen. To override the source, simply leave this parameter empty.
boolean
True if compression was performed or false if something failed
compressJpgPictureFolder(string $imagesPath) : boolean
This method will apply the compression to all files, so the folder shall contain only images to prevent errors. IMPORTANT: Files are replaced by the optimized version.
string
Full file system path to a folder containing images that will be replaced by a compressed version
boolean
True if processing was performed or false if something failed
thumbnailGenerate(string $source, integer $width, integer $height, string $destination = '', string $mode = 'crop', \org\turbocommons\src\main\php\utils\number $quality = 87, string $bgColor = '000000', string $focalCenter = '') : resource
Requires GD php extension enabled to work.
string
The binary string containing the source picture
integer
The thumbnail destination width (If empty (''), resize mode will become 'fit' automatically with a fixed height)
integer
The thumbnail destination height (If empty (''), resize mode will become 'fit' automatically with a fixed width)
string
The path where thumbnail will be saved (including the filename). If not specified, thumb won't be saved to disk
string
The thumb resize and scale mode:
\org\turbocommons\src\main\php\utils\number
The jpg quality of the generated thumb, from 0 to 100. 87 by default
string
The thumb background color as an HEX string. Only used with the pad scale mode. 000000 by default (black)
string
The point of the original picture that retains the maximum interest (for example 32x100), so when cropping, the thumb will be centered as much as possible in relation to this point. (Optional and only used with crop mode).
resource
The generated thumb image GD resource, so we can manipulate it directly in memory, output it to the browser with imagejpeg($returnedResource) or store it in a binary string variable with ob_start(); imagejpeg($returnedResource); $binaryString = ob_get_contents(); ob_end_flush();