ホームページ  >  記事  >  バックエンド開発  >  PHP gd ライブラリはウォーターマーク実装コードをページに追加します

PHP gd ライブラリはウォーターマーク実装コードをページに追加します

WBOY
WBOYオリジナル
2016-07-25 08:53:421068ブラウズ
  1. header ("content-type: image/png");

  2. $conn = mysql_connect("localhost", "root", "");データベース
  3. $colname_rs_article = $_get['id'] //パラメータ ID を取得

  4. mysql_select_db("cms", $conn) //SQL を実行

  5. $query_rs_article = sprintf("select *article_id = %s", $colname_rs_article);
  6. $rs_article = mysql_query($query_rs_article, $conn) または die(mysql_error());
  7. $row_rs_article = mysql_fetch_assoc($rs_article);
  8. $totalrows_rs_article = mysql_num_rows( $rs_article ; //背景を白に設定します
  9. imagefill($image, 0, 0, $bg);
  10. $text_color = imagecolorallocate($image, 0, 0, 0) //テキストの色を黒に設定します
  11. imagestring ($image, 5 , 0, 0, $row_rs_article['title'], $text_color) //記事のタイトルを出力
  12. imagestring($image, 3, 0, 20, $row_rs_article['author'], $text_color ); //記事を出力します Author
  13. imagestring($image, 4, 0, 60, $row_rs_article['content'], $text_color) //記事の内容を出力します
  14. $logo = imagecreatefrompng('logo.png'); //ウォーターマーク画像を取得
  15. $ logow = images($logo);
  16. imagecopy($image, $logo, 0, 0, 0, 0, $logow, $logo); /テキスト画像と透かし画像を結合します
  17. imagejpeg($image) // ブラウザに出力します
  18. imagedestroy($logo)
  19. ?>

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