Good morning, everyone 、 Good afternoon 、 Good evening ~
Today I will share one python How to add watermark ~ After learning, you don't have to add watermarks by yourself ,
Just click to run ~ python It's done for you by itself ! Only required 2 That's ok Python Code , Anyone can learn .
This article Article code provider : Qingdeng Education - Self Travel
First, let's prepare something , Help us run the code better
Python 3.8
Pycharm
choice file( file ) >>> setting( Set up ) >>> Project( project ) >>> python interpreter(python Interpreter )
Click on the gear , choice add
add to python The installation path
choice file( file ) >>> setting( Set up ) >>> Plugins( plug-in unit )
Click on Marketplace Enter the name of the plug-in you want to install such as : Translation plug-ins Input translation / Chinese plug-in Input Chinese
Select the corresponding plug-in and click install( install ) that will do
After successful installation Yes, it will pop up restart pycharm The option to Click ok , Restart to take effect
Insinuation of insinuation , Ha ha ha ha ha ha ha
The installation and download speed is too slow , Or wrong , You can switch the image source installation ~
How do you use it? filestools Module? ?
First, import a method in the module ,watermarker , light marker , then import add_mark
from watermarker.marker import add_mark
add_mark() Methods 8 Parameters , If you don't know how to view parameters , stay jupyter notebook You can enter the following command , You can view it .
file: Photos to be watermarked ;
mark: What words are used as watermarks ;
out: Location saved after adding watermark ;
color: The color of the watermark font , Default color #8B8B1B;
size: Watermark font size , Default 50;
opacity: Transparency of watermark font , Default 0.15;
space: Interval between watermark Fonts , Default 75 A space ;
angle: Rotation angle of watermark font , Default 30 degree ; Next , We only use one line of code , Add a watermark to the picture .
add_mark('C:\\Users\\ Qingdeng Education \\Desktop\\111\\1.jpg', mark=' give the thumbs-up 、 Focus on 、 Collect ', opacity=0.5)
The link here is a link to a single image ~
You can click on image properties —> Security —> See the object name
good , So let's run this , Look at our results
Original picture :
design sketch :
from watermarker.marker import add_mark
import os
# use os The module reads all the contents of the folder , Use files receive .
files = os.listdir('C:\\Users\\ Qingdeng Education \\Desktop\\111')
for file in files:
add_mark('C:\\Users\\ Qingdeng Education \\Desktop\\111\\'+file, mark=' give the thumbs-up 、 Focus on 、 Collect ', opacity=0.5)
Need source code and Python I can get the information for free ~
We can study more details by ourselves ~
Yes , The following folder ( That is, the file generated for you after running the code ) If you want to run it again, please delete it , Otherwise, it will be wrong
Okay , My article ends here !
There are more suggestions or questions to comment on or send me a private letter ! Come on together and work hard (ง •_•)ง
If you like, just pay attention to the blogger , Or like the collection and comment on my article !!!