PHP サイト用の一般的な画像のアップロードが必要です。写真とロゴは、大きすぎず、デザインに合うように、ある程度サイズを変更する必要があります。
私はこのコードでそれを試しています:
function resize($width,$height) {
$new_image = imagecreatetruecolor($width, $height);
if($this->image_type == PNG or $this->image_type == GIF) {
imagealphablending($new_image, false);
imagesavealpha($new_image,true);
$transparent = imagecolorallocatealpha($new_image, 255, 255, 255, 127);
imagefilledrectangle($new_image, 0, 0, $nWidth, $nHeight, $transparent);
}
imagecopyresized($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
$this->image = $new_image;
}
ただし、アルファ値が 0 ~ 255 の領域を持つ画像をアップロードすると、完全な黒に置き換えられ、アンチエイリアス領域が黒い境界線に変わります。
完全な透明度は PNG と GIF では問題なく機能しますが、半透明の領域だけが問題になります。
問題を説明するのに正しい用語を使用していない場合は申し訳ありません。