Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

imageflip

Description

The imageflip of Image for PHP flips an image using a given mode.

Syntax

imageflip(
    GdImage $image,
    int $mode
): bool

Parameters

image

A GdImage object, returned by one of the image creation functions, such as imagecreatetruecolor().

mode

Flip mode.

ConstantDescription
IMG_FLIP_HORIZONTALFlips the image horizontally.
IMG_FLIP_VERTICALFlips the image vertically.
IMG_FLIP_BOTHFlips the image both horizontally and vertically.

Return

Returns true on success or false on failure.

Examples

1 · return

<?

$width = 100;
$height = 100;
$image = imagecreate($width, $height);

$mode = IMG_FLIP_HORIZONTAL;

$return = imageflip($image, $mode);
    
var_export($return);

?>
true

2 · base64 · mode · IMG_FLIP_HORIZONTAL

<?

$width = 100;
$height = 100;
$image = imagecreatetruecolor($width, $height);

$red = 255;
$green = 255;
$blue = 255;
$color = imagecolorallocate($image, $red, $green, $blue);

$font = 1;
$x = 0;
$y = 0;
$string = "string";
imagestring($image, $font, $x, $y, $string, $color);

$mode = IMG_FLIP_HORIZONTAL;
imageflip($image, $mode);

ob_start();

    imagepng($image);

$output = ob_get_clean();

echo '<!doctype html>
<html>
<body>
    <img src="data:image/png;base64,' . base64_encode($output) . '">
</body>
</html>';

?>
<!doctype html>
<html>
<body>
    <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAhklEQVR4nO3TQQoDMQgAQO3//2wPpW1wQ3oo7EFmDiFEhURMBJxV1Z8JfG2b9bj/Hjeot/Uklhb8jK5rS57m8OyWsI3GZbIm96uNw2HTquI4gzO/YURkZmZuQ60d18Kq+tS+NpMnK8Y/DwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARnkCHGuMh9VYfNwAAAAASUVORK5CYII=">
</body>
</html>

3 · base64 · mode · IMG_FLIP_VERTICAL

<?

$width = 100;
$height = 100;
$image = imagecreatetruecolor($width, $height);

$red = 255;
$green = 255;
$blue = 255;
$color = imagecolorallocate($image, $red, $green, $blue);

$font = 1;
$x = 0;
$y = 0;
$string = "string";
imagestring($image, $font, $x, $y, $string, $color);

$mode = IMG_FLIP_VERTICAL;
imageflip($image, $mode);

ob_start();

    imagepng($image);

$output = ob_get_clean();

echo '<!doctype html>
<html>
<body>
    <img src="data:image/png;base64,' . base64_encode($output) . '">
</body>
</html>';

?>
<!doctype html>
<html>
<body>
    <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAjElEQVR4nO3TUQrDIAwAUOP975x9yKRLW9YNxph770OqRjEhbQ0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPgBmZmZ337Fx+RdWSwfh/FnYavWq0dERLTHzCPiLOERPMa9tTurj/RmyaY5LU1UbNcP71lN+bO23bGv1JXdhZur+qNUX9TfOKOaPHcD2I56qmSdnxsAAAAASUVORK5CYII=">
</body>
</html>

4 · base64 · mode · IMG_FLIP_BOTH

<?

$width = 100;
$height = 100;
$image = imagecreatetruecolor($width, $height);

$red = 255;
$green = 255;
$blue = 255;
$color = imagecolorallocate($image, $red, $green, $blue);

$font = 1;
$x = 0;
$y = 0;
$string = "string";
imagestring($image, $font, $x, $y, $string, $color);

$mode = IMG_FLIP_BOTH;
imageflip($image, $mode);

ob_start();

    imagepng($image);

$output = ob_get_clean();

echo '<!doctype html>
<html>
<body>
    <img src="data:image/png;base64,' . base64_encode($output) . '">
</body>
</html>';

?>
<!doctype html>
<html>
<body>
    <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAlElEQVR4nO3UywrCMBAF0F7x/395XASjpDXgIgTlnEXpa8L0kulxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAfKGqqmp3F79giKlftpN6+lR1Lm9uq/rdbbKzkvTjZWGSIbgkSe5rWt2vZdG+vN35lN2QzhBiX2dhr3udB60P4PsL86fzmeXlMp2//WfN2SnLPQDU6nevw7VoJgAAAABJRU5ErkJggg==">
</body>
</html>
HomeMenu