Page 1 of 1
image size comparison functions
Posted: Wed Apr 21, 2004 5:06 pm
by Unipus
does GD or some other image library have the capability to retrieve image pixel dimensions? What I want to do is compare and determine automatically whether an image is vertically or horizontally oriented.
Posted: Wed Apr 21, 2004 5:31 pm
by MarK (CZ)
Posted: Wed Apr 21, 2004 6:05 pm
by Unipus
thanks for that. now, a more sophisticated question (sorry, I'm a bit unfamiliar with the capabilities of PHP imaging):
If I wanted to take an image, expand the canvas, rotate it slightly (so that corner-to-corner it approximately fills the new canvas), and then make the parts of the canvas with no image data transparent and save as 24-bit PNG - can that be done? If it can be done, would the quality and filesize be acceptable?
Posted: Wed Apr 21, 2004 6:11 pm
by feyd
I don't know of any internal images to do arbitrary rotation. You'll need to find a script/roll-your-own to handle it. Fairly tricky sometimes.
Posted: Wed Apr 21, 2004 6:21 pm
by Unipus
I sorta figured. And I figured the "make the canvas transparent" bit would be even trickier than that.
Posted: Wed Apr 21, 2004 6:28 pm
by feyd
that's not too hard actually.. depending on your desired effect.. i.e. alpha channel, or single color.. even then, it's not hard that I know of.
Posted: Wed Apr 21, 2004 6:33 pm
by Unipus
Hmm. Apparently there is a function to do it.
http://www.php.net/manual/en/function.imagerotate.php
I don't know if I could assign alpha transparency to the revealed background (as opposed to a palette color), but the rotating can be done by any float value.
Posted: Wed Apr 21, 2004 6:34 pm
by feyd
huh.. I hadn't seen that in the function list.. or remember it anyway.. far too many functions on that darn list.