Location: PHPKode > projects > Top Music module > Top Music 3.0.7/html/modules/topMusic/lib/com/sergids/common/Image.php
<?php

class Image{
	function createThumbnail($src,$ws=200,$hs=0){
		if (extension_loaded('gd')){
			if(false !== (list($width,$height,$type,$attr) = @getimagesize($src))){
				if($ws>0){
			       $ratio=$ws/$width;
			       $ht = $height * $ratio;
			       $wt = $ws;
		       	}elseif($hs>0){
		       		$ratio=$hs/$height;
		       		$wt = $width * $ratio;
		       		$ht = $hs;
		       	}
		        switch($type){
		        	case 1: //gif
		        		$type="gif";
		        		break;
		        	case 2: //jpg
		        		$type="jpeg";
		        		break;
		        	case 3: //png
		        		$type="png";
		        		break;
		        }
		        $ht_name=round($ht);
		        $wt_name=round($wt);
		        if(!file_exists($src."_thumb".$wt_name."x".$ht_name.".".$type)){
	        		$thumb = imagecreatetruecolor($wt,$ht);
	        		$source = call_user_func("imagecreatefrom".$type,$src);
	        		imagecopyresampled($thumb,$source,0,0,0,0,$wt,$ht,$width,$height);
	        		call_user_func("image".$type,$thumb,$src."_thumb".$wt_name."x".$ht_name.".".$type);
	        		imagedestroy($thumb);
		        }
		        return $src."_thumb".$wt_name."x".$ht_name.".".$type;
	       }else
	       		return null;
		}else
			return null;
			
   }
}  
?>
Return current item: Top Music module