rotating an image with PHP

Discussion in 'PHP' started by siraxi, Aug 8, 2006.

  1. #1
    Hi

    How could I rotate an external image with PHP?

    Thanks!
     
    siraxi, Aug 8, 2006 IP
  2. dddougal

    dddougal Well-Known Member

    Messages:
    676
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    108
    #2
    have a table in mysql and a list of the order you want the images in. insert a 1 or a zero on the row you want or dont want displaying and upgrade it everytime.

    Or use another variable to decide, the date or something.
     
    dddougal, Aug 8, 2006 IP
  3. Cryogenius

    Cryogenius Peon

    Messages:
    1,280
    Likes Received:
    118
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Have a look at these two threads. They should point you in generally the right direction. You just need to adapt the code to show random images instead of ads.


    Unless I've completely misunderstood you, and you want to actually rotate an image by some angle so that it's another way up? You'll probably want to use ImageMagick for this.

    Cheers, Cryo.
     
    Cryogenius, Aug 8, 2006 IP
  4. siraxi

    siraxi Peon

    Messages:
    333
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #4
    oh, sorry, my bad English! I actually meant turning an image, like around its center.
    I have an image and want to turn it with a certain number of degrees clockwise or counterclockwise.

    Sorry for the misunderstanding! Thanks for the replies.
     
    siraxi, Aug 8, 2006 IP
  5. CCD

    CCD Peon

    Messages:
    330
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Try phpThumb.

    I use it on most of my sites and can verify it works great and does just about anything you could want... :)
     
    CCD, Aug 8, 2006 IP
  6. coderlinks

    coderlinks Peon

    Messages:
    282
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Try the imagerotate function in the GD library:
    http://in2.php.net/manual/en/function.imagerotate.php
    
    $filename = 'hooba.jpg';
    $angle = '90'; // in degrees
    
    $img = imagcreatefromjpeg($filename);
    $rotimg = imagerotate($img,$angle,0);
    
    header('Content-type: image/jpeg'); // set the correct Content-type for output
    imagejpeg($rotimg); // send output to browser
    
    imagedestroy($img);
    imagedestroy($rotimg);
    
    PHP:
    The last zero in the imagerotate call means that it should not ignore the transparent colors. If you use a non-zero value there, the transparent colors will be ignored.

    Thomas
     
    coderlinks, Aug 8, 2006 IP
  7. siraxi

    siraxi Peon

    Messages:
    333
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Many Thanks!
     
    siraxi, Aug 8, 2006 IP
  8. topwebserv

    topwebserv Guest

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    you can search in php.net it have sample for you.
     
    topwebserv, Aug 8, 2006 IP