Magento has own resize engine that can resize catalog image on your own desire width and height.That means you can resize image with fixed width and variable height or you can set fixed height with variable width.Also you can resize image with no white background in magento means you remove white background from your image background.So to fit or remove white background use keepFrame(false).
please take a quik look of some functions that I have used in below coding like :
constrainOnly(bool $flag) : it guarantees that image will not be bigger than it was.we can use it before resize() and default value is true.
keepAspectRatio(bool $flag) : it guarantees that image width/height will not be contorted.we can use it before resize() and default value is true.
keepFrame(bool $flag) : it guarantees that image will have dimension and white background can managed if image is not fit with desired dimention.That means set keepFrame(false) remove the background and set image with desired width/height
for fixed with I have width : 500
for fixed with I have height : 500
Also you can specify the height and width image to image would not exceed that you have mentioned.
You can resize image through Varien_Image if you are using code in custom script or any where else.
I am here checked if there is rsized image or not if not I am creating a new resized image propertioanly with heght and width with Varien_Image.
Sometimes you have only image url like http://jyotiranjan.in/customimage/testimage.jpg so you want to resize that.For that lets how I am resizing that image.Now I am creating a resized folder and have to save that resized image in that folder.