Пример #1
0
 /**
  *  Rotates an image.
  *
  *  @param mixed $options Can either be an integer with the degrees or an array with
  *                        keys `bgcolor` for the rotation bgcolor and `degrees` for
  *                        the angle.
  *  @return bool
  */
 public function rotateImage($options = [])
 {
     try {
         if (is_array($options)) {
             if (empty($options['bgcolor'])) {
                 $options['bgcolor'] = -1;
             }
             $this->image->rotate($options['degrees'], $options['bgcolor']);
             return true;
         }
         $this->image->rotate($options);
         return true;
     } catch (Exception $e) {
         array_push($this->errors, $e->getMessage());
         return false;
     }
 }
Пример #2
0
use Elboletaire\Watimage\Image;
$image_file = FILES . 'peke.jpg';
$orientate = FILES . 'tripi.jpg';
/*********************
 *** RESIZE IMAGES ***
 *********************/
$image = new Image($image_file);
// allowed types: resize [or classic], reduce, min [or resizemin], crop and resizecrop
$image->resize('resizecrop', 400, 200)->generate(OUTPUT . 'image1-resizecrop.jpg');
/*********************
 *** ROTATE IMAGES ***
 *********************/
$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);