Problema con el cambio de tamaño de imagen en PHP: gd crea imágenes con el tamaño feo

Estoy creando miniaturas de altura y ancho fijos desde mi script PHP usando la siguiente función

/*creates thumbnail of required dimensions*/
function createThumbnailofSize($sourcefilepath,$destdir,$reqwidth,$reqheight,$aspectratio=false)
{
    /*
     * $sourcefilepath =  absolute source file path of jpeg
     * $destdir =  absolute path of destination directory of thumbnail ending with "/"
     */
    $thumbWidth = $reqwidth; /*pixels*/
    $filename = split("[/\\]",$sourcefilepath);
    $filename = $filename[count($filename)-1];
    $thumbnail_path = $destdir.$filename;
    $image_file = $sourcefilepath;

    $img = imagecreatefromjpeg($image_file);
    $width = imagesx( $img );
    $height = imagesy( $img );

    // calculate thumbnail size
    $new_width = $thumbWidth;
    if($aspectratio==true)
    {
        $new_height = floor( $height * ( $thumbWidth / $width ) );
    }
    else
    {
        $new_height = $reqheight;
    }

    // create a new temporary image
    $tmp_img = imagecreatetruecolor( $new_width, $new_height );

    // copy and resize old image into new image
    imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );

    // save thumbnail into a file

    $returnvalue = imagejpeg($tmp_img,$thumbnail_path);
    imagedestroy($img);
    return $returnvalue;
}

y llamo a esta función con los siguientes parámetros

createThumbnailofSize($sourcefilepath,$destdir,48,48,false);

pero el problema es que la imagen resultante es de muy mala calidad, cuando realizo la misma operación con la tienda de Adobe Photo, se realiza una buena conversión ... ¿por qué es así? No puedo encontrar ningún parámetro de calidad, a través del cual cambio la calidad de la imagen de salida.

Respuestas a la pregunta(5)

Su respuesta a la pregunta