Jump to content

Calling function info


graham23s

Recommended Posts

Hi Guys,

 

Just getting started using functions more and more now, but i'm having trouble here is the code:

 

function:

 

     ############################################# 
     # Thumbnail code                            
     #############################################   
     function resize_images($filename,$uploaddirectory,$var_loggedinuser) {  
     
        ## Find out the files extension 
        $ext = explode(".", $filename); 
        $ext = $ext[count($ext)-1]; 
          
        ## random numbers 
        $randomnumber = rand(0,999999999); 
          
          if($ext == "jpg" || $ext == "jpeg")     
           
              $image = imagecreatefromjpeg($uploaddirectory); 
               
          elseif($ext == "png") 
           
              $image = imagecreatefrompng($uploaddirectory); 
               
          elseif($ext == "gif") 
           
              $image = imagecreatefromgif($uploaddirectory); 
               
        ## save the file in %     
        $size = 0.50; 
         
        ## rename the thumbnail 
        $newimagename_thumb = $var_loggedinuser. "-" .time(); 
        $save = "thumbs/$newimagename_thumb.$ext"; 
               
        ## get the files dimensions 
        list($width,$height) = getimagesize($uploaddirectory); 
         
        $modwidth = $width * $size;  
        $modheight = $height * $size;  
        $thumbnail = imagecreatetruecolor($modwidth, $modheight) ;  
        imagecopyresampled($thumbnail, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height);         
        ## imagejpeg($thumbnail, $save, 100);  
         
        if($ext == 'jpg' || $ext == 'jpeg') 
      
        imagejpeg($thumbnail, $save, 100); 
      
        if($ext == 'gif') 
      
        imagegif($thumbnail, $save, 100); 
      
        if($ext == 'png') 
      
        imagepng($thumbnail, $save, 100); 
        
        return($save);
        
        }

 

calling the function:

 

resize_images($filename,$uploaddirectory,$var_loggedinuser);

 

what im having trouble with is, how do i get information FROM the function i need:

 

$newimagename_thumb.$ext

 

this bit of information back from the function to use when displaying the thumbnail not sure how to acomplish this any help would be great guys

 

Cheers

 

Graham

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.