<?php
$mediaPath=Mage::getBaseDir('media')."/catalog/category/resized/";
if(!is_dir($mediaPath)) mkdir($mediaPath,0777);
foreach($collections as $subcate){
$_curCat_sub = Mage::getModel('catalog/category')->load($subcate->getId());
$count_sub = $_curCat_sub->getProductCount();
$_subimage=$subcate->getThumbnail();
if($_subimage!=''){
$_imageUrl=Mage::getBaseDir('media')."/catalog/category/".$subcate->getThumbnail(); //Real path
$_imageUrl=Mage::getBaseDir('media')."/catalog/category/".$subcate->getThumbnail();
$imageResized=Mage::getBaseDir('media')."/catalog/category/resized/".$subcate->getThumbnail();
$imageObj = new Varien_Image($_imageUrl);
$imageObj->constrainOnly(TRUE);
$imageObj->keepAspectRatio(TRUE);
$imageObj->keepFrame(FALSE);
$imageObj->resize(null,300);
$imageObj->save($imageResized);
$mediaurl= Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
$imageResized = $mediaurl."/catalog/category/resized/".$subcate->getThumbnail();
?>
<img src="<?php echo $imageResized;?>"/>
<?php } ?>