Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    3

    question about create thumbnail

    Hello

    I need create thumbnail of many formats of images. I know how do it on php with help of GD lib. But i need support many more format of files.

    Please advise me solution of my problem.
    Thanks.


    Kind regards,
    Dmitry

  2. #2
    Member
    Join Date
    Feb 2006
    Posts
    50
    Looking into this...
    Ilya
    eBoundHost
    Fast Dedicated Servers, Web Hosting, Hosting Company Acquisitions
    ilya (at) eBoundHost (dot) com

  3. #3

  4. #4
    I dont know but what about ImageMagick and other duilt in php scripts?
    Strat with Linux || Optimize, Secure and increase performance of Apache || Already Started
    The visionary conceives the impossible, The missionary makes it possible. ...Gita.

  5. #5
    Junior Member
    Join Date
    Aug 2006
    Posts
    8
    This is a function I used once for an image upload script. It works really well, the only thing I don't know how to do is how to preserve transparency (in gifs and pngs) when generating the thumbnail.



    Code:
    function createthumb($name,$filename,$new_w,$new_h){
    
    	$system=explode('.',$name);
    
    	if (preg_match('/jpg|jpeg|JPG/',$system[1])){
    
    		$src_img=imagecreatefromjpeg($name);
    
    	}
    
    	if (preg_match('/png|PNG/',$system[1])){
    
    		$src_img=imagecreatefrompng($name);
    
    	}
    
    	if (preg_match('/gif|GIF/',$system[1])){
    
    		$src_img=imagecreatefromgif($name);
    
    	}
    
    
    
    
    $old_x=imageSX($src_img);
    
    $old_y=imageSY($src_img);
    If($old_x <= $new_w && $old_y <= $new_h){
    
    
    
    	$dst_img=ImageCreateTrueColor($old_x,$old_y);
    
    	imagecopyresampled($dst_img,$src_img,0,0,0,0,$old_x,$old_y,$old_x,$old_y); 
    	if (preg_match("/png/",$system[1]))
    
    	{	
    
    	imagepng($dst_img,$filename); 
    
    	} 
    
    	if (preg_match("/gif/",$system[1]))
    
    	{
    
    	imagegif($dst_img,$filename);
    
    	}
    
    	else {
    
    	imagejpeg($dst_img,$filename); 
    
    	}
    
    
    
    
    
    }else {
    
    if ($old_x > $old_y) {
    
    	$thumb_w=$new_w;
    
    	$thumb_h=$old_y*($new_h/$old_x);
    
    }
    
    if ($old_x < $old_y) {
    
    	$thumb_w=$old_x*($new_w/$old_y);
    
    	$thumb_h=$new_h;
    
    }
    
    if ($old_x == $old_y) {
    
    	$thumb_w=$new_w;
    
    	$thumb_h=$new_h;
    
    }
    
    
    
    $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
    
    	imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); 
    
    
    
    
    
    if (preg_match("/png/",$system[1]))
    
    {
    
    	imagepng($dst_img,$filename); 
    
    } 
    
    if (preg_match("/gif/",$system[1]))
    
    {
    
    	imagegif($dst_img,$filename);
    
    }
    
    else {
    
    	imagejpeg($dst_img,$filename); 
    
    }
    
    imagedestroy($dst_img); 
    
    imagedestroy($src_img); 
    
    }
    }

  6. #6
    Junior Member
    Join Date
    Aug 2006
    Posts
    5
    Yeah, ImageMagick is your best bet
    http://www.galaxy-solutions.net

    Galaxy-Solutions
    1-888-751-0100 ext. 52
    Dedicated Servers Starting from only $24.99/month

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

  Find Web Hosting      
  Shared Web Hosting UNIX & Linux Web Hosting Windows Web Hosting Adult Web Hosting
  ASP ASP.NET Web Hosting Reseller Web Hosting VPS Web Hosting Managed Web Hosting
  Cloud Web Hosting Dedicated Server E-commerce Web Hosting Cheap Web Hosting


Premium Partners:


Visit forums.thewebhostbiz.com: to discuss the web hosting business, buy and sell websites and domain names, and discuss current web hosting tools and software.