Hi,

Does anyone have a script that is used to upload and resize the all type of images? I have script to resize upload and JPG files only but i need GIF, BMP and others too.

Thanks

Hi this is nathen,

i think this is some what usefull to you,

if($_FILES[userfile][name]!='')
	{
	if($num<=0)
	{
		$rand=time();
		$uploaddir="uploads/stores/";
		$filetype2=$_FILES[userfile][type];
		$filename=$_FILES[userfile][name];
		$realpath=$uploaddir.$filename;
		
		if(!empty($filetype2)) 
		{	
		
			if(move_uploaded_file($_FILES['userfile']['tmp_name'],$realpath )) 
			{
			
			}
			
			/************************************Resizing the image 75x75****************/
		$path="uploads/stores";
		$bgim_file_name = $path."/".$filename; 
		$bgimage_attribs = getimagesize($bgim_file_name);
	
		if($filetype2=='image/gif')	
				{
			$bgim_old = imagecreatefromgif($bgim_file_name); 
				}	
		else	
				{
			 $bgim_old = imagecreatefromjpeg($bgim_file_name);
				}
					
		$bgth_max_width = 75; //for Album image
		$bgth_max_height = 75;
		$bgratio = ($bgwidth > $bgheight) ? $bgth_max_width/$bgimage_attribs[0] : $bgth_max_height/$bgimage_attribs[1];
	
		$bgth_width = 75;//$image_attribs[0] * $ratio; 
		$bgth_height = 75;//$image_attribs[1] * $ratio;
	
		$bgim_new = imagecreatetruecolor($bgth_width,$bgth_height); 
		imageantialias($bgim_new,true); 
		$bgth_file_name = "uploads/stores/thumbnails/$filename";
					 
		imagecopyresampled($bgim_new,$bgim_old,0,0,0,0,$bgth_width,$bgth_height, $bgimage_attribs[0], $bgimage_attribs[1]);
	
		if($filetype2=='image/gif')	
				{									
				imagegif($bgim_new,$bgth_file_name,100); 
				}	
		else	
				{
			imagejpeg($bgim_new,$bgth_file_name,100);
				}
				
		}
This article has been dead for over six months. Start a new discussion instead.