Trim::setImage
Set the source image and the output path
Description
public void Trim::setImage( string $org_path, string $cnv_path )
Loads the source image. The output format is decided by the extension of $cnv_path: jpg (or jpeg), png or gif. A JPEG photo is turned the way its Exif orientation says.
Throws a \RuntimeException when:
$org_pathis not a file;- the extension of
$cnv_pathis notjpg,jpeg,pngorgif; $org_pathis not a JPEG, PNG or GIF image, or cannot be read.
Arguments
| Name | Data type | Default | Remarks |
|---|---|---|---|
| $org_path | string | Source image path | |
| $cnv_path | string | Output image path (.jpg, .jpeg, .png or .gif) |
Example
Controller
use Fegg\Tool\Trim;
$trim = new Trim();
try {
$trim->setImage('path/to/image.jpg', 'path/to/converted.jpg');
} catch (\RuntimeException $e) {
// missing file, not an image, or another output type
}