/** * Flip method for PHP versions < 5.5.0 * * @param string $type Type of flip, can be any of: horizontal, vertical, both * @return Image */ public function convenienceFlip($type = 'horizontal') { $type = Normalize::flip($type); $resampled = $this->imagecreate($this->width, $this->height); // @codingStandardsIgnoreStart switch ($type) { case IMG_FLIP_VERTICAL: imagecopyresampled($resampled, $this->image, 0, 0, 0, $this->height - 1, $this->width, $this->height, $this->width, 0 - $this->height); break; case IMG_FLIP_HORIZONTAL: imagecopyresampled($resampled, $this->image, 0, 0, $this->width - 1, 0, $this->width, $this->height, 0 - $this->width, $this->height); break; // same as $this->rotate(180) // same as $this->rotate(180) case IMG_FLIP_BOTH: imagecopyresampled($resampled, $this->image, 0, 0, $this->width - 1, $this->height - 1, $this->width, $this->height, 0 - $this->width, 0 - $this->height); break; } // @codingStandardsIgnoreEnd $this->image = $resampled; return $this; }
/** * @expectedException Elboletaire\Watimage\Exception\InvalidArgumentException */ public function testFlipFail() { Normalize::flip('fail'); }