Like Mark says, you can use the getimagesize() function to obtain data about the image dimensions.
However, forcing an image to a certain width-height without maintaining the original ratio usually causes some pretty weird looking images. The way I do this on my site, is to first of all determine wich would cause me most trouble, if the image is too high or too wide. I have thought about this a number of times, and the conclusion always lands on 'wide'. So, if I use 100px for image width, and an image is less than 100px, geez, let it be. I don't care if the image is smaller, as long as it isn't larger and mess up my design.
So, what I'm going to paste you a portion of one of my scripts for image size conversion. Just to give you a hint on how I do it 🙂
$imageData holds information gathered using getimagesize(). So, basically, what I do is find a number that I can multiply the image width with to get an image with ~= $SETUP[image_tnWidth] pixels. If I now multiply the height by the same factor, I will get the image with the same ratio between height/width, yet scaled to a smaller image. Of course, you can do the same thing if you want to blow up smaller images. (Obviously you'd have to increase the $factor instead of decreasing it)
$factor = $SETUP[image_tnConvFactor]; / 1 by default /
$newWidth = $imageData[image_width] $factor;
while ($newWidth > $SETUP[image_tnWidth]) {
$factor -= 0.01;
$newWidth = round($imageData[image_width] $factor);
}
$newHeight = round($imageData[image_height] * $factor);
And now you'd have to perform the image size conversion, or just use the numbers for height/width in the <img>-tag. your call, hope it helped 🙂