Page 1 of 1

GD - Getting width/height of image in memory?

Posted: Sat Feb 21, 2004 8:20 pm
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.

Posted: Sun Feb 22, 2004 8:29 pm
by tsg
Try this

Code: Select all

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

?>