1
私はこのコードを使用して、その場で画像のサイズを変更し、そのコピーを作成しています。PHPイメージのサイズ変更黒の背景 - 色の変更
function ak_img_resize($target, $newcopy, $w, $h, $ext) {
list($w_orig, $h_orig) = getimagesize($target);
$scale_ratio = $w_orig/$h_orig;
if (($w/$h) > $scale_ratio) {
$w = $h * $scale_ratio;
} else {
$h = $w/$scale_ratio;
}
$img = "";
$ext = strtolower($ext);
if ($ext == "gif"){
$img = imagecreatefromgif($target);
} else if($ext =="png"){
$img = imagecreatefrompng($target);
} else {
$img = imagecreatefromjpeg($target);
}
$tci = imagecreatetruecolor($w, $h);
// imagecopyresampled(dst_img, src_img, dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h)
imagecopyresampled($tci, $img, 0, 0, 0, 0, $w, $h, $w_orig, $h_orig);
imagejpeg($tci, $newcopy, 80);
}
は、しかし、私は好きではないのは、それがデフォルトに黒背景を提供します。どのように私はこれを変更することができます黒のような背景に白?
ここでは、次のとおりです。
私の友人は伝説です! – Frank