PHP 8.3.4 Released!

アルファチャネルを使用した、画像へのすかしの追加

例1 アルファチャネルを使用した、画像へのすかしの追加

<?php
// スタンプと、それをすかしとして適用する写真を読み込みます
$stamp = imagecreatefrompng('stamp.png');
$im = imagecreatefromjpeg('photo.jpeg');

// スタンプの余白を設定し、スタンプ画像の幅と高さを取得します
$marge_right = 10;
$marge_bottom = 10;
$sx = imagesx($stamp);
$sy = imagesy($stamp);

// スタンプ画像を写真の上にコピーします。余白の値と
// 写真の幅を元にスタンプの位置を決定します
imagecopy($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp));

// 出力し、メモリを開放します
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>
アルファチャネルを使用した、画像へのすかしの追加
この例は、すかしやスタンプを写真あるいは著作権つき画像に追加するための一般的な方法です。 スタンプ画像内のアルファチャネルのテキストはアンチエイリアス処理されることに注意しましょう。 画像をコピーしてもこれは残り続けます。

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top