public \Joomla\CMS\Image\Image
flip
(mixed $mode, mixed $createNew = true)
/**
* Method to flip the current image.
*
* @param integer $mode The flip mode for flipping the image {@link http://php.net/imageflip#refsect1-function.imageflip-parameters}
* @param boolean $createNew If true the current image will be cloned, flipped and returned; else
* the current image will be flipped and returned.
*
* @return Image
*
* @since 3.4.2
* @throws \LogicException
*/
public function flip($mode, $createNew = true)
{
// Create the new truecolor image handle.
$handle = imagecreatetruecolor($this->getWidth(), $this->getHeight());
// Copy the image
imagecopy($handle, $this->getHandle(), 0, 0, 0, 0, $this->getWidth(), $this->getHeight());
// Flip the image
if (!imageflip($handle, $mode)) {
throw new \LogicException('Unable to flip the image.');
}
// If we are resizing to a new image, create a new Image object.
if ($createNew) {
// @codeCoverageIgnoreStart
return new static($handle);
// @codeCoverageIgnoreEnd
}
// Free the memory from the current handle
$this->destroy();
// Swap out the current handle for the new image handle.
$this->handle = $handle;
return $this;
}