Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lib_base
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikang
lib_base
Commits
2fb61535
Commit
2fb61535
authored
Apr 12, 2019
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
upadte cript
parent
6f825567
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
script/image_mark.py
+6
-6
No files found.
script/image_mark.py
View file @
2fb61535
...
...
@@ -3,11 +3,7 @@ import os
import
sys
import
random
from
PIL
import
Image
,
ImageDraw
,
ImageFont
def
add_text_to_image
(
image
,
text
):
mode
=
'RGB'
if
image
.
endswith
(
".png"
):
mode
=
"RGBA"
def
add_text_to_image
(
image
,
text
,
mode
):
#水印字体随机大小
font_size
=
random
.
randint
(
30
,
60
)
font
=
ImageFont
.
truetype
(
'Arial.ttf'
,
font_size
)
...
...
@@ -34,8 +30,12 @@ def add_text_to_image(image, text):
return
image_with_text
if
__name__
==
'__main__'
:
mode
=
'RGB'
if
sys
.
argv
[
1
]
.
endswith
(
".png"
):
mode
=
"RGBA"
img
=
Image
.
open
(
sys
.
argv
[
1
])
im_after
=
add_text_to_image
(
img
,
sys
.
argv
[
2
])
im_after
=
add_text_to_image
(
img
,
sys
.
argv
[
2
]
,
mode
)
output
=
sys
.
argv
[
1
]
.
split
(
"."
);
output
=
output
[
0
]
+
"_mark"
+
"."
+
output
[
1
]
print
(
output
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment