Estoy buscando la manera de poder generar una imagen thumbnail de buena calidad y poco peso.
Que recomiendan usar, he probado con GD y con ImageMagick pero no logro obtener buenos resultados
esta es la imagen png[URL="http://imgur.com/BRBCu"]http://imgur.com/BRBCu[/URL]
y la he querido generar en 157x115 en jpg
con estas funciones
esta en GD
Código PHP:
   function createThumbnail($img, $imgPath, $suffix, $newWidth, $newHeight, $quality, $to = 'jpg')
{
  // Open the original image.
  //$original = imagecreatefromjpeg("$imgPath/$img") or die("Error Opening original");
  $original = imagecreatefrompng("$imgPath/$img") or die("Error Opening original");
  list($width, $height, $type, $attr) = getimagesize("$imgPath/$img");
 
  // Resample the image.
  $tempImg = imagecreatetruecolor($newWidth, $newHeight) or die("Cant create temp image");
  //imagecopyresized($tempImg, $original, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height) or die("Cant resize copy");
  imagecopyresampled($tempImg, $original, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height) or die("Cant resize copy");
 
  // Create the new file name.
  $newNameE = explode(".", $img);
  //$newName = ''. $newNameE[0] .''. $suffix .'.'. $newNameE[1] .'';
  $newName = ''. $newNameE[0] .''. $suffix .'.'. $to .'';
 
  // Save the image.
  if($to == 'jpg'){
    imagejpeg($tempImg, "$imgPath/$newName", $quality) or die("Cant save image");
  }
  if($to == 'png'){
    //echo ceil( $quality / 10 );
    if($quality < 100){
        imagepng($tempImg, "$imgPath/$newName" , ceil( $quality / 10 )) or die("Cant save image");
    }else{
        imagepng($tempImg, "$imgPath/$newName" ) or die("Cant save image");
    }
  }
 
  // Clean up.
  imagedestroy($original);
  imagedestroy($tempImg);
  return true;
} 
    Código PHP:
   function createThumbIMK($img, $imgPath, $thumbDir, $suffix, $newWidth, $newHeight, $to = 'jpg' , $quality = '100',$optimize = false) {
  // add in the suffix after the '.' dot.
    $newNameE = explode(".", $img);
    $newName = ''. $newNameE[0] .''. $suffix .'.'. $to .'';
 
  // ImageMagicK doesnt like '/' and 'x' characters in the command line call.
    $uploadedImg = ''. $imgPath .'/'. $img .'';
    $newThumb = ''. $thumbDir .'/'. $newName .'';
    $newRes = ''. $newWidth .'x'. $newHeight .'';
 
 
    $ct = system("/usr/bin/convert -strip -quality $quality%  -resize $newRes $uploadedImg $newThumb", $retval);
    
    
        
    if($to == 'jpg' && $optimize){
        $ct = exec("c:\jpegoptim\jpegoptim.exe -p -t -f --strip-all $newThumb", $retval);
        //$ct = exec("/jpegoptim -p -t -f --strip-all $newThumb", $retval);
        //echo $ct.'<br>';
    }
    if($to == 'png' && $optimize){        
        $ct = exec("/usr/bin/optipng $newThumb", $retval);
    }
    return $ct;
} 
    En cambio en photoshop, con la opcion "guardar para la web" a 80% las imagenes en jpg y 157x115 se ven muy bien.
Agradezco cualquier tipo de informacion
Saludos.
 
 
 Consulta sobre generacion de thumbnail
 Consulta sobre generacion de thumbnail 


