note 61749 deleted from function.imagecopy by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 14:55:27 +0000 |
| Subject: | note 61749 deleted from function.imagecopy by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-197240@lists.php.net to get a copy of this message | ||
Note Submitter: relsqui at chiliahedron dot com
----
Here's an alternative image-flipping function which is simpler than either of the ones
I've seen in the docs here. It takes the source image and the mode (zero for horizontal,
nonzero for vertical) and returns the flipped image.
<?php
function imageflip($image, $mode) {
$w = imagesx($image);
$h = imagesy($image);
$flipped = imagecreate($w, $h);
if ($mode) {
for ($y = 0; $y < $h; $y++) {
imagecopy($flipped, $image, 0, $y, 0, $h - $y - 1, $w, 1);
}
} else {
for ($x = 0; $x < $w; $x++) {
imagecopy($flipped, $image, $x, 0, $w - $x - 1, 0, 1, $h);
}
}
return $flipped;
}
?>