9951 explained code solutions for 126 technologies


php-gdHow to flip an image


<?php

$file = '/var/www/examples/heroine.png';
$im = imagecreatefrompng($file);

imageflip( $im, IMG_FLIP_VERTICAL );
imagePng($im, '/tmp/image.png');ctrl + c
$file

image to rotate

imagecreatefrompng

creates GD image object from given PNG image

imageflip

flips given image in a specified direction

IMG_FLIP_VERTICAL

flips image vertically, explore other options

imagePng

saves image in PNG format to the given path


How to flip an image, php gd

Usage example

<?php

$file = '/var/www/examples/heroine.png';
$im = imagecreatefrompng($file);

imageflip( $im, IMG_FLIP_VERTICAL );
imagePng($im, '/tmp/image.png');