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
dba12402
Commit
dba12402
authored
Apr 12, 2019
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update script
parent
d7430bec
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
0 deletions
+61
-0
script/image_mark.py
+38
-0
script/mark_screen_img.py
+17
-0
script/script_help.sh
+6
-0
No files found.
script/image_mark.py
0 → 100755
View file @
dba12402
#!/usr/bin/env python3
import
os
import
sys
import
random
from
PIL
import
Image
,
ImageDraw
,
ImageFont
def
add_text_to_image
(
image
,
text
):
#水印字体随机大小
font_size
=
random
.
randint
(
30
,
60
)
font
=
ImageFont
.
truetype
(
'Arial.ttf'
,
font_size
)
# 添加背景
new_img
=
Image
.
new
(
'RGBA'
,
(
image
.
size
[
0
]
*
3
,
image
.
size
[
1
]
*
3
),
(
0
,
0
,
0
,
0
))
new_img
.
paste
(
image
,
image
.
size
)
# 添加水印
font_len
=
len
(
text
)
rgba_image
=
new_img
.
convert
(
'RGBA'
)
text_overlay
=
Image
.
new
(
'RGBA'
,
rgba_image
.
size
,
(
255
,
255
,
255
,
0
))
image_draw
=
ImageDraw
.
Draw
(
text_overlay
)
#随机位置
for
i
in
range
(
random
.
randint
(
0
,
100
),
rgba_image
.
size
[
0
],
font_len
*
font_size
+
font_size
*
2
):
for
j
in
range
(
random
.
randint
(
0
,
100
),
rgba_image
.
size
[
1
],
font_size
*
5
):
image_draw
.
text
((
i
,
j
),
text
,
font
=
font
,
fill
=
(
0
,
0
,
0
,
50
))
text_overlay
=
text_overlay
.
rotate
(
-
45
)
image_with_text
=
Image
.
alpha_composite
(
rgba_image
,
text_overlay
)
# 裁切图片
image_with_text
=
image_with_text
.
crop
((
image
.
size
[
0
],
image
.
size
[
1
],
image
.
size
[
0
]
*
2
,
image
.
size
[
1
]
*
2
))
return
image_with_text
if
__name__
==
'__main__'
:
img
=
Image
.
open
(
sys
.
argv
[
1
])
im_after
=
add_text_to_image
(
img
,
sys
.
argv
[
2
])
output
=
sys
.
argv
[
1
]
.
split
(
"."
);
output
=
output
[
0
]
+
"_mark"
+
"."
+
output
[
1
]
print
(
output
)
im_after
.
save
(
output
)
script/mark_screen_img.py
0 → 100755
View file @
dba12402
#!/usr/bin/env python3
import
json
import
string
import
random
import
glob
,
os
import
sys
for
root
,
dirs
,
files
in
os
.
walk
(
"/Users/connor/Documents/App_GP/"
):
directory
=
os
.
path
.
join
(
os
.
getcwd
(),
root
)
for
file
in
files
:
dir_name
=
root
.
split
(
"/"
);
dir_name
=
dir_name
[
len
(
dir_name
)
-
1
]
if
dir_name
.
startswith
(
sys
.
argv
[
1
]
+
"_"
):
if
file
.
endswith
(
".png"
)
and
"_mark"
not
in
file
:
path
=
os
.
path
.
join
(
directory
,
file
)
os
.
system
(
"./image_mark.py "
+
path
+
" "
+
sys
.
argv
[
2
]
.
split
(
"."
)[
0
])
\ No newline at end of file
script/script_help.sh
View file @
dba12402
...
...
@@ -16,6 +16,7 @@ echo "13、copy apk"
echo
"14、生成工具包"
echo
"15、功能代码同步"
echo
"16、压缩切图"
echo
"17、给GP图片添加水印"
...
...
@@ -128,6 +129,11 @@ then
chmod a+x tinypng.py
./tinypng.py
-d
../../app/src/main/res/drawable-xxhdpi
elif
((
$commod
==
'17'
))
then
.
../../gradle.properties
chmod a+x mark_screen_img.py
./mark_screen_img.py
"
${
corp_id
}
"
"
${
app_id
}
"
else
echo
"找不到编号"
...
...
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