IT Community - Software Programming, Web Development and Technical Support

Rotating Images with PHP

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 ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > PHP Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-17-2007, 08:36 AM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,162
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Rotating Images with PHP

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
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT -7. The time now is 02:14 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0