Results 1 to 9 of 9

Thread: Flip OR Flop an image

  1. #1
    Join Date
    Mar 2007
    Location
    Michigan
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Flip OR Flop an image

    I am looking for a way (with PHP or JS) to flip (sometimes called flop) an image horizontally. Same image only flipped as a mirror reverse. I have house plans on my site and people like to view the plans reversed at times and I have never pulled that off.

    Any ideas or script? I just want to click on the link to flip the image, then click the link again (or another one) to flip it back.

    Thank you,
    Steve Nyhof

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    You could make 2 images (one normal and one reversed), then use javascript to change the source of the image to the mirrored one and visa versa.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Mar 2007
    Location
    Michigan
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I have found the fliph() function. only works in IE, but thats ok. I have thousands of images. I am not going to make duplicates. I knew there was a function, I just didn't know what it was called. I have it working now with just on button, but have more work to do.

    Thank you for your reply.

  4. #4
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    So forget about non-IE users? Haha.
    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

  5. #5
    Join Date
    Mar 2007
    Location
    Michigan
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    While I enjoy FF, most of my clients (builders) are IE users because they have learned where the start button is to the computer, and that the big blue E means - serf the web. So I am stuck with IE. Sometimes I go to their office and find the screen res at 640 x 480 because something reset.

    I am also a builder so I can pick on them. The difference is that I have been monkeying with computers for over 17 years.

  6. #6
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    Haha, I see.
    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Can you just set a negative width on the images? I forget if this works or not.

    You can use the PHP GD library to reverse them, but this would process each pixel and be a stress on your server.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #8
    Join Date
    Mar 2007
    Location
    Michigan
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I am interested in PHP because that's what my site is run on. I have looked into the flop function?? but cannot find enough info to help me. I am currently learning javascript and PHP through online courses, but I really need to figure this thing out.

    I want to be able to flip a number of images (elevation and floor plans) inside a div or something like an id=
    Any help?

  9. #9
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    PHP Code:
    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$image0$y0$h $y 1$w1);
                    }
            } else {
                    for (
    $x 0$x $w$x++) {
                            
    imagecopy($flipped$image$x0$w $x 101$h);
                    }
            }
            return 
    $flipped;
    }
    ?>
    From: http://www.php.net/imagecopy
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •