Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to add text watermark to pictures by PHP

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to add text watermark to pictures by PHP". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to add text watermarks to pictures by PHP".

PHP adds a text watermark instance to the picture, supports Chinese text watermark, whether to overwrite the original image, and customizes the background color, text color, font and so on.

Watermark water.class.php

Var $Path = ". /"; / / the directory where the picture resides relative to the relative path of the page calling this class var $FileName = ""; / / the name of the picture, such as "1.jpg" var $Text = ""; / / the watermark text to be added to the picture, which supports Chinese var $TextColor = "# ffffff"; / / the color of the text, the font color can only be black var $TextBgColor = "# 000000" for gif images. / / the color of the background bar of the text var $Font = "c://windows//fonts//simhei.ttf"; / / the directory where the font is stored, the relative path var $OverFlag = true; / / whether to overwrite the original image, default to overwrite, if not, automatically + "_ water_down" after the file name of the original image, such as "1.jpg" = > "1_water_down.jpg" var $BaseWidth = 200 / / the width of the image must be at least > = 200 before the watermark text will be added.

Call the watermark class

Include_once 'water.class.php'; $objImg = new sucaihuoWaterChinese (); $objImg- > Path = "images/"; $objImg- > FileName = "1.jpg"; $objImg- > Text = iconv (' UTF-8','GB2312',' material www.sucaihuo.com'); $objImg- > Font = ". / fonts/simhei.ttf"; / / font location $objImg- > TextBgColor = "# ffffff"; / / text background color $objImg- > TextColor = "# ffffff"; / / text color $objImg- > OverFlag = false / / whether to overwrite the original image $objImg- > Run (); at this point, I believe you have a better understanding of "how to add text watermarking to pictures by PHP". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report