imageflip() function in PHP



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 = 'http://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:

Updated on: 2019-12-31T07:18:28+05:30

317 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements