/** * Generates the image file. * * @param string $path if not specified image will be printed on screen * @param string $output mime type for output image (image/png, image/gif, image/jpeg) * @return true on success. Otherwise false */ public function generate($path = null, $output = null) { try { $this->image->generate($path, $output); return true; } catch (Exception $e) { array_push($this->errors, $e->getMessage()); return false; } }
*********************/ $image = new Image($image_file); // check out Normalize::color to see all the allowed possibilities about how // to set colors. Angle must be specified in degrees (positive is clockwise) $image->rotate(90, '#fff')->generate(OUTPUT . 'image2-rotate.jpg'); // Images are automatically orientated by default when using the constructor // instead of load. You can skip it and you can also auto-orientate images later: // disable auto-orientate on load $image = new Image($orientate, false); // we can later use the autoOrientate method if we not did it previously: $image->autoOrientate()->generate(OUTPUT . 'image3-auto-orientate.jpg'); /********************************** *** EXPORTING TO OTHER FORMATS *** **********************************/ $image = new Image($image_file); $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');