GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 08-Jun-2009, 06:51
seaders seaders is offline
New Member
 
Join Date: Jun 2008
Posts: 8
seaders is on a distinguished road

Retrieving the size of a rotated image


I'm using GD2 with PHP 5.2.9.2 and I'm trying to create a dynamic compass type thing. What I'd like is simply an arrow image that will change where it's pointing based on the
Code:
?=rotate
get variable I pass to it. Problem is that because the image is square, imagerotate (the function I'm using) makes the overall canvas bigger and bigger, to it's maximum size, at any of the 45 degree angles. This is not what I expected, nor what I want, what I'd much prefer is it to stay exactly in it's place and clipping to occur. I understand how I could do this manually, but to do so, I'd need the dimensions of the newly rotated image, in it's current form, rather than how it was. The only function I can see that does something like that,
Code:
getimagesize()
only works for images loaded directly from a file, rather than a resource (which is what imagerotate returns). Is there another function that gives you the same as what getimagesize() does, but for a manipulated resource?

Thanks guys.
  #2  
Old 08-Jun-2009, 09:48
seaders seaders is offline
New Member
 
Join Date: Jun 2008
Posts: 8
seaders is on a distinguished road

Re: Retrieving the size of a rotated image


for anyone interested, it's the functions imagesx and imagesy that give you the width and height of a resource image.
  #3  
Old 19-Jun-2009, 17:58
Blake's Avatar
Blake Blake is offline
Regular Member
 
Join Date: Nov 2005
Posts: 330
Blake is a jewel in the roughBlake is a jewel in the roughBlake is a jewel in the rough

Re: Retrieving the size of a rotated image


Why don't you just compute the new size? If the original image is w x w, and you rotate by an angle theta, the new size will be w*(sin(theta) + cos(theta)). I've attached an image that shoes why this formula works. It may be off by a pixel due to rounding error, but is should give you a good enough estimate.
Attached Images
File Type: jpg square.jpg (18.4 KB, 10 views)
__________________
www.blake-foster.com
 
 

Recent GIDBlogProblems with the Navy (Officers) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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 Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Image onto JFrame tedds Java Forum 8 25-Oct-2007 20:04
Need Help With Recursive Functions jonas12rena C Programming Language 1 31-Jul-2006 11:12
GIM gidedit - a fltk fluid resize project cable_guy_67 FLTK Forum 2 01-Jun-2005 15:00
Checking source codes of image, audio and video files onauc C Programming Language 5 26-Feb-2005 21:47
Having a problem Chuckles Computer Hardware Forum 19 13-Sep-2004 12:17

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 10:39.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.