The imageflip() function is used to flip an image using given mode.
Syntax
bool imageflip(img, mode )
Parameters
img: An image resource created using imagecreatetruecolor()
mode: The flip mode. Here are the possible values:
IMG_FLIP_HORIZONTAL – Flips the image horizontally.
IMG_FLIP_VERTICAL – Flips the image vertically.
IMG_FLIP_BOTH – Flips the image both horizontally and vertically.
Return
The imageflip() function returns TRUE on success or FALSE on failure.
Example
The following is an example that flips an image horizontally:
<?php $img_file = 'https://www.tutorialspoint.com/images/tp-logo-diamond.png'; header('Content-type: image/png'); $img = imagecreatefrompng($img_file); imageflip($img, IMG_FLIP_HORIZONTAL); imagejpeg($img); imagedestroy($img); ?>
Output
The following is the output: