/** * Crops an image based on specified coords and size. * * @param mixed $options Specifying x & y position and width & height, like * so [ * 'x' => 23, * 'y' => 23, * 'width' => 230, * 'height' => 230 * ] * @return bool success */ public function crop($options = []) { try { $this->image->crop($options); return true; } catch (Exception $e) { array_push($this->errors, $e->getMessage()); return false; } }
$image->generate(OUTPUT . 'image4-formats.png', 'image/png'); /******************* *** FLIP IMAGES *** *******************/ $image = new Image($image_file); // vertical [or y, or v], horizontal [or x, or h] // check out Normalize::flip to see all the allowed possibilities $image->flip('vertical')->generate(OUTPUT . 'image5-flip.jpg'); /*********************** *** CROPPING IMAGES *** ***********************/ // Usefull for cropping plugins like https://github.com/tapmodo/Jcrop $image = new Image($image_file); // Values from the cropper // check out Normalize::crop to see all the allowed possibilities $image->crop(['width' => 500, 'height' => 500, 'x' => 50, 'y' => 80])->generate(OUTPUT . 'image6-crop.jpg'); /************************ *** APPLYING FILTERS *** ************************/ $image = new Image($image_file); $image->blur()->sepia()->pixelate(3, true)->vignette()->generate(OUTPUT . 'image7-effects.jpg'); /******************************** *** DIRECTLY TREATING IMAGES *** ********************************/ $image = new Image($image_file); // Get the resource image $resource = $image->getImage(); // Add a string as a note in the top left side $color = imagecolorallocate($resource, 0, 0, 0); imagestring($resource, 5, 10, 10, "My cat, peke", $color); // Return the image resource to the Image instance