this function really saved my day !!!
well for testing i should upload several jpg some had jfif encoding ,
so some are color losing when i include them in fpdf ,tcpdf (i tryed 2 open sources to minimize errors to know wht's wrong) .
the thumb function i used now (fixed) is
public static function jpgtofilethumb($file,$thumb,$lun,$quality){
//de la php.net
list ($x, $y) = @getimagesize ($file);
$img = @imagecreatefromjpeg ($file);
if ($x > $y) {
$tx = $lun;
$ty = round($lun / $x * $y);
} else {
$tx = round($lun / $y * $x);
$ty = $lun;
}
$thb = imagecreatetruecolor ($tx, $ty);
// Enable interlancing
if(imageistruecolor($thb)) imageinterlace($thb, true);
imagecopyresampled ($thb,$img, 0,0, 0,0, $tx,$ty, $x,$y);
imagejpeg ($thb, $thumb, $quality);
imagedestroy ($thb);
imagedestroy ($img);
}