GD - Getting width/height of image in memory?

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
User avatar
Albright
Forum Newbie
Posts: 20
Joined: Sat Sep 13, 2003 8:03 pm
Contact:

GD - Getting width/height of image in memory?

Post by Albright »

I'm searching through PHP's GD functions, and, unless I'm totally blind, I can't find a function that will calculate the size of a GD image in memory; only getimagesize(), which only works with images on disk.

I have some images that are imagerotate()'d by arbitrary amounts, and this causes them to be resized. I'd like to know how wide those images are after they are rotated. I suppose I could write some function that figures it out based on the degree of rotation, but since I suck at such math, I'd rather not. Writing the image to disk and then using getimagesize() would be even worse... Is there a simpler way to just get the width of an image resource?

TIA.
tsg
Forum Contributor
Posts: 142
Joined: Sun Jan 12, 2003 9:22 pm
Location: SE, Alabama
Contact:

Post by tsg »

Try this

Code: Select all

<?php
	$width = imagesx($image);
	$height = imagesy($image);

?>
Post Reply