The14thGOD Posted March 27, 2008 Share Posted March 27, 2008 I'm trying to figure out how to make this function work, I'm not as familiar with functions and this function doesn't seem to have anything more to explain it. I found it here: http://www.php.net/manual/en/ref.image.php#62029 <?php // This is a correction to the image-flipping function I posted previously. // The bitwise ands (&) were incorrectly written as logical ands (&&). // Needless to say, that breaks the function in obnoxious--if amusing--ways. define("VERTICAL", 1); define("HORIZONTAL", 2); function imageflip($image, $mode) { $w = imagesx($image); $h = imagesy($image); $flipped = imagecreate($w, $h); if ($mode & VERTICAL) { for ($y = 0; $y < $h; $y++) { imagecopy($flipped, $image , 0, $y, 0, $h - $y - 1, $w, 1); } } if ($mode & HORIZONTAL) { for ($x = 0; $x < $w; $x++) { imagecopy($flipped, $image , $x, 0, $w - $x - 1, 0, 1, $h); } } return $flipped; } ?> I've called the function before and put the image location into where image is but I'm confused on the mode. Anyone familiar with this? Any help would be great, thanks in advance. Justin Quote Link to comment https://forums.phpfreaks.com/topic/98113-php-flip-image/ Share on other sites More sharing options...
Barand Posted March 27, 2008 Share Posted March 27, 2008 Different MODE results [pre] O O \ / original \ HORIZONTAL / X X X VERTICAL / / O Quote Link to comment https://forums.phpfreaks.com/topic/98113-php-flip-image/#findComment-501950 Share on other sites More sharing options...
The14thGOD Posted March 27, 2008 Author Share Posted March 27, 2008 What? I don't understand how I choose vert/horizontal...it says if mode & vert then do this, but...the only 2 arguments are image and mode... Quote Link to comment https://forums.phpfreaks.com/topic/98113-php-flip-image/#findComment-501980 Share on other sites More sharing options...
Barand Posted March 27, 2008 Share Posted March 27, 2008 $flipped = flip_image ($image, VERTICAL); Quote Link to comment https://forums.phpfreaks.com/topic/98113-php-flip-image/#findComment-502494 Share on other sites More sharing options...
The14thGOD Posted March 28, 2008 Author Share Posted March 28, 2008 Alright, that clears up some of it, like I said I'm new to functions and I appreciate the help. I've run into a problem displaying the image, here's some examples of what I've tried <?php include("includes/flip_image.php"); $image = "images/sideimgs/side02.jpg"; imageflip("images/sideimgs/side02.jpg",HORIZONTAL); //imageflip($image,HORIZONTAL); ?> <img class="rightimg" src="<?= $flipped ?>" width="154" height="768" alt="Side Image" /> I've also tried putting 1 line into where the $flipped is, so $flipped = imageflip($image,HORIZONTAL). Nothing shows up in the code when i look at the source, it looks like src="". Again, ty for the help. Quote Link to comment https://forums.phpfreaks.com/topic/98113-php-flip-image/#findComment-502903 Share on other sites More sharing options...
Barand Posted March 28, 2008 Share Posted March 28, 2008 $image needs to be a GD image, not a filename. Quote Link to comment https://forums.phpfreaks.com/topic/98113-php-flip-image/#findComment-503472 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.