The imageflip() function is an inbuilt function in PHP which is used to Flip an image horizontally, vertically or both horizontally and vertically using the given mode.
Syntax:
bool imageflip( $image, $mode )
Parameters: This function accepts two parameters as mentioned above and described below:
- $image: The imagecreatetruecolor() function is used to create a blank image in a given size.
- $mode: This parameter is used to hold the Flip mode of image. This can be one of the IMG_FLIP_* constants:
- 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 Value: This function returns TRUE on success or FALSE on failure.
Below programs illustrate the imageflip() function in PHP.
Note: The image given below is used in the following program.

Program 1:
<?php // Assign image file in variable. $image_name = 'geeks.png'; // Load image file $image = imagecreatefrompng($image_name); // Flip the image vertically imageflip($image, IMG_FLIP_VERTICAL); // Content type header('Content-type: image/png'); // Output imagejpeg($image); ?> |
Output:

Program 2:
<?php // Assign image file to variable $image_name = 'geeks.png'; // Load image file $image = imagecreatefrompng($image_name); // Flip the image horizontally imageflip($image, IMG_FLIP_HORIZONTAL); // Content type header('Content-type: image/png'); // Output imagejpeg($image); ?> |
Output:

Program 3:
<?php // Assign image file to variable $image_name = 'geeks.png'; // Load image file $image = imagecreatefrompng($image_name); // Flip the image file both horizontally // and vertically. imageflip($image, IMG_FLIP_BOTH); // Content type header('Content-type: image/png'); // Output imagejpeg($image); ?> |
Output:

Related Articles:
- PHP | imagedashedline() Function
- PHP | imagefilledpolygon() Function
- PHP | imagefilledellipse() Function
Reference: http://php.net/manual/en/function.imageflip.php
Recommended Posts:
- How to get the function name inside a function in PHP ?
- PHP 5 vs PHP 7
- PHP | Get PHP configuration information using phpinfo()
- PHP | php.ini File Configuration
- How to import config.php file in a PHP script ?
- PHP | imagecreatetruecolor() Function
- PHP | fpassthru( ) Function
- PHP | ImagickDraw getTextAlignment() Function
- PHP | Ds\Sequence last() Function
- PHP | Imagick floodFillPaintImage() Function
- Function to escape regex patterns before applied in PHP
- PHP | array_udiff_uassoc() Function
- PHP | geoip_continent_code_by_name() Function
- PHP | GmagickPixel setcolor() function
- PHP | opendir() Function
- PHP | cal_to_jd() Function
- PHP | stream_get_transports() Function
- PHP | Ds\Deque pop() Function
- PHP | SimpleXMLElement children() Function
- PHP | array_intersect_ukey() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

