写真のサイズを変更する関数を使用しています。
ほとんどの画像は非常にうまくリサイズされています。しかし、誰か、なぜ黒人だけなのかわかりません。同じ画像は常に黒の結果になります。これを与えるのは一種のJpegかもしれません..しかし、それを変更するにはどうすればよいですか?
ありがとう !
function create_image($file) {
if(is_file($file)) {
$size = getimagesize($file);
// y =hauteur en pixel
$y = 800;
$x = $size[0]/$size[1]*$y;
//$y = 75; # Taille en pixel de l'image redimensionnée
if ($size) {
if ($size['mime']=='image/jpeg' ) {
$img_big = imagecreatefromjpeg($file);
$img_new = imagecreate($x, $y);
# création de la miniature
$img_mini = imagecreatetruecolor($x, $y)
or $img_mini = imagecreate($x, $y);
// copie de l'image, avec le redimensionnement.
imagecopyresized($img_mini,$img_big,0,0,0,0,$x,$y,$size[0],$size[1]);
imagejpeg($img_mini,$file );
}
elseif ($size['mime']=='image/png' ) {
$img_big = imagecreatefrompng($file);
$img_new = imagecreate($x, $y);
# création de la miniature
$img_mini = imagecreatetruecolor($x, $y)
or $img_mini = imagecreate($x, $y);
// copie de l'image, avec le redimensionnement.
imagecopyresized($img_mini,$img_big,0,0,0,0,$x,$y,$size[0],$size[1]);
imagepng($img_mini,$file );
}
elseif ($size['mime']=='image/gif' ) {
$img_big = imagecreatefromgif($file);
$img_new = imagecreate($x, $y);
# création de la miniature
$img_mini = imagecreatetruecolor($x, $y)
or $img_mini = imagecreate($x, $y);
// copie de l'image, avec le redimensionnement.
imagecopyresized($img_mini,$img_big,0,0,0,0,$x,$y,$size[0],$size[1]);
imagegif($img_mini,$file );
}
// move_uploaded_file($img_mini,$dir."test");
}
return true;
} else {
return false;
}
}
編集:ありがとう!
最適化は良いです...
他の画像では、結果は良好です!!! 私は約25枚の画像をテストしましたが、2枚だけで問題が発生しました...なぜ????