Image resizing and uploading

Reply

Join Date: Apr 2008
Posts: 496
Reputation: veledrom is an unknown quantity at this point 
Solved Threads: 0
veledrom veledrom is offline Offline
Posting Pro in Training

Image resizing and uploading

 
0
  #1
Mar 23rd, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 64
Reputation: jeffc418 is an unknown quantity at this point 
Solved Threads: 0
jeffc418 jeffc418 is offline Offline
Junior Poster in Training

Re: Image resizing and uploading

 
0
  #2
Mar 23rd, 2009
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 28
Reputation: nathenastle is an unknown quantity at this point 
Solved Threads: 2
nathenastle's Avatar
nathenastle nathenastle is offline Offline
Light Poster

Re: Image resizing and uploading

 
0
  #3
Mar 24th, 2009
Hi this is nathen,

i think this is some what usefull to you,

  1. if($_FILES[userfile][name]!='')
  2. {
  3. if($num<=0)
  4. {
  5. $rand=time();
  6. $uploaddir="uploads/stores/";
  7. $filetype2=$_FILES[userfile][type];
  8. $filename=$_FILES[userfile][name];
  9. $realpath=$uploaddir.$filename;
  10.  
  11. if(!empty($filetype2))
  12. {
  13.  
  14. if(move_uploaded_file($_FILES['userfile']['tmp_name'],$realpath ))
  15. {
  16.  
  17. }
  18.  
  19. /************************************Resizing the image 75x75****************/
  20. $path="uploads/stores";
  21. $bgim_file_name = $path."/".$filename;
  22. $bgimage_attribs = getimagesize($bgim_file_name);
  23.  
  24. if($filetype2=='image/gif')
  25. {
  26. $bgim_old = imagecreatefromgif($bgim_file_name);
  27. }
  28. else
  29. {
  30. $bgim_old = imagecreatefromjpeg($bgim_file_name);
  31. }
  32.  
  33. $bgth_max_width = 75; //for Album image
  34. $bgth_max_height = 75;
  35. $bgratio = ($bgwidth > $bgheight) ? $bgth_max_width/$bgimage_attribs[0] : $bgth_max_height/$bgimage_attribs[1];
  36.  
  37. $bgth_width = 75;//$image_attribs[0] * $ratio;
  38. $bgth_height = 75;//$image_attribs[1] * $ratio;
  39.  
  40. $bgim_new = imagecreatetruecolor($bgth_width,$bgth_height);
  41. imageantialias($bgim_new,true);
  42. $bgth_file_name = "uploads/stores/thumbnails/$filename";
  43.  
  44. imagecopyresampled($bgim_new,$bgim_old,0,0,0,0,$bgth_width,$bgth_height, $bgimage_attribs[0], $bgimage_attribs[1]);
  45.  
  46. if($filetype2=='image/gif')
  47. {
  48. imagegif($bgim_new,$bgth_file_name,100);
  49. }
  50. else
  51. {
  52. imagejpeg($bgim_new,$bgth_file_name,100);
  53. }
  54.  
  55. }
Last edited by peter_budo; Mar 26th, 2009 at 11:11 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC