with ImageMagick you can get the width and height of an image by running:
Code:
image=yourimage.png
width=$(identify -format '%w' $image)
height=$(identify -format '%h' $image)
Then you can use $width and $height as the dimensions of the picture you want to resize.
You can resize a picture so that its width and/or height doesn't go
beyond a certain dimension:
Code:
convert yourimage.png -resize '128x128>' resized.png
Check this web site for a lot of examples:
http://www.imagemagick.org/Usage/