PHP | imageflip() Function (original) (raw)

Last Updated : 11 Jul, 2025

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,image, image,mode )

Parameters: This function accepts two parameters as mentioned above and described below:

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 `

image=imagecreatefrompng(image = imagecreatefrompng(image=imagecreatefrompng(image_name); // Flip the image vertically imageflip($image, IMG_FLIP_VERTICAL); // Content type header('Content-type: image/png'); // Output imagejpeg($image); ?>

`

Output: image flip Program 2:

php `

image=imagecreatefrompng(image = imagecreatefrompng(image=imagecreatefrompng(image_name); // Flip the image horizontally imageflip($image, IMG_FLIP_HORIZONTAL); // Content type header('Content-type: image/png'); // Output imagejpeg($image); ?>

`

Output: flip image Program 3:

php `

image=imagecreatefrompng(image = imagecreatefrompng(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: image flip Related Articles:

Reference: https://www.php.net/manual/en/function.imageflip.php