Question: I'm using timthumb to resize my images because it scales them nicely if I only enter one of the dimensions. However I want to know if it's possible to extract the new resized image's dimensions so that I can add that dynamically to the img tag attributes.

I tried this with no luck:

```
$fullpath = '/lib/timthumb.php?src='.$image.'&w=100';
$my_image = array_values(getimagesize($fullpath));
list($width, $height, $type, $attr) = $my_image;

```

Any ideas?

Answer: 
While I'm not sure how to read the thumb generated in the cache by timthumb directly, this should work:

```
$fullpath = '/lib/timthumb.php?src='.$image.'&w=' . $newWidth;

#array with 0 being the width, and 1 being the height, and some other values as well
$oldDims = getimagesize($image);

#timthumb uses floor(), so mimicing here
$newHeight = floor($newWidth / $oldDims[0] * $oldDims[1]); 

```
My idea would be to scale the images before they are uploaded to the server. If you have a lot of images resizing them this way is an expensive operation. Also you don't need timthumb php can do this on it's own. So if you really *need* to resize images on the server try something like...

```
$size = gewtimagesize($image);
$dimensions = $size['3'];//returns height="xxx" width="xxx"
$img = <<<IMG
    <img src="path/to/img" $dimensions >
IMG;
echo $img;

```

I don't know if it works, but it looks right to me

--EDIT--
Nevermind this won't work for you