ホームページ  >  記事  >  バックエンド開発  >  PHP で画像に透かしを入れる原理 (超簡単なサンプルコード)_PHP チュートリアル

PHP で画像に透かしを入れる原理 (超簡単なサンプルコード)_PHP チュートリアル

WBOY
WBOYオリジナル
2016-07-21 15:14:05880ブラウズ

テキストの透かし:

コードをコピーします コードは次のとおりです:

$w = 80;
$h = 20;
$textcolor = imagecolorallocate( $im, 123, 12, 255);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128); , 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $grey); //長方形を描いて塗りつぶします

//画像の左上隅に文字列を書き込みます
imagestring($im, 3, 2, 3, "Hello world!", $textcolor);

// 出力画像
header("Content-type: image/jpeg")
imagedestroy ($im);

$groundImg = "DSC05940.jpeg";
$ground_w = $groundInfo[0]; $ground_h = $groundInfo[1 ];
switch($groundInfo[2]){
ケース 1:
$ground_im = imagecreatefromgif($groundImg);
break;
ブレイク;
$ground_im = imagecreatefrompng($groundImg);
$waterImg = "DSC05949.jpeg"
$water_w = $imgInfo[ 0];
$water_w = $imgInfo[1];

switch($imgInfo[2]){
ケース 1:
$water_im = imagecreatefromgif($waterImg);
$water_im = imagecreatefromjpeg ($waterImg);
break ;
$water_im = imagecreatefrompng($waterImg)
}
imagecopy($ground_im,$water_im,0,0,500,500); : image/jpeg");

imagejpeg($ground_im);


PHP には、画像を結合するための多くの関数が用意されています: 例: imagecopymerge、imagecopyresize



http://www.bkjia.com/PHPjc/326347.html

www.bkjia.com

本当

http://www.bkjia.com/PHPjc/326347.html

技術記事

テキストのウォーターマーク: $w = 80; $h = 20; $textcolor = imagecolorallocate($im, 123, 12, 255); ($im、25...




声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。