This is a discussion on Rotating Images with PHP within the PHP Programming forums, part of the Web Development category; Image rotation in PHP is handled by a function called imagerotate(), which takes three parameters (and optionally a fourth, which ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Image rotation in PHP is handled by a function called imagerotate(), which takes three parameters (and optionally a fourth, which deals with transparency and is beyond the scope of this guide). The first is the resource identifier which you obtain when you load the original image within your script, the second is the angle which you want to rotate the image and the third parameter is used when the image isn't going to be rectangular, and specifies the colour with which to fill the uncovered areas of the rotated image to make it into a rectangle (since all image formats require rectangular images). <? // filename of the original image $fileName = "cow.jpg"; // degrees to rotate the image (counter clockwise) $angle = 45.0; // if the resulting image is not rectangular.. // .. what colour will the uncovered bits be? $bgColour = 0xFFFFFF; // red // load the original image from the file $original = imagecreatefromjpeg($fileName); // rotate the image by $angle degrees $rotated = imagerotate($original, $angle, $bgColour); // print the appropriate header type // this tells the browser we're displaying a jpeg image header('Content-type: image/jpeg'); // use the imagejpeg() method to display the rotated image imagejpeg($rotated); ?>
__________________ With, J. Jeyaseelan Everything Possible |
| Sponsored Links |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Rotating an image caption in javascript | mobilegeek | HTML, CSS and Javascript Coding Techniques | 5 | 10-12-2007 06:46 AM |
| Problem in Rotating TextField | seesamjagan | Flash Actionscript Programming | 1 | 08-29-2007 04:03 AM |
| Rotating an Image | muthukumar | HTML, CSS and Javascript Coding Techniques | 1 | 07-30-2007 03:18 AM |
| Watermarking Images | ewriter | Java Programming | 2 | 05-08-2007 03:13 AM |
| Rotating Password script | aquariancore | PHP Programming | 2 | 02-16-2007 07:57 AM |