image size comparison functions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Unipus
Forum Contributor
Posts: 409
Joined: Tue Aug 26, 2003 2:06 pm
Location: Los Angeles, CA

image size comparison functions

Post 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.
User avatar
MarK (CZ)
Forum Contributor
Posts: 239
Joined: Tue Apr 13, 2004 12:51 am
Location: Prague (CZ) / Vienna (A)
Contact:

Post by MarK (CZ) »

Unipus
Forum Contributor
Posts: 409
Joined: Tue Aug 26, 2003 2:06 pm
Location: Los Angeles, CA

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Unipus
Forum Contributor
Posts: 409
Joined: Tue Aug 26, 2003 2:06 pm
Location: Los Angeles, CA

Post by Unipus »

I sorta figured. And I figured the "make the canvas transparent" bit would be even trickier than that.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Unipus
Forum Contributor
Posts: 409
Joined: Tue Aug 26, 2003 2:06 pm
Location: Los Angeles, CA

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

huh.. I hadn't seen that in the function list.. or remember it anyway.. far too many functions on that darn list.
Post Reply