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
efe8bd97
Commit
efe8bd97
authored
Oct 22, 2019
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update script
parent
53616f23
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
37 deletions
+37
-37
script/print/screen_maker.py
+37
-37
No files found.
script/print/screen_maker.py
View file @
efe8bd97
#-*-coding:utf-8-*-
# -*-coding:utf-8-*-
import
os
import
sys
import
random
import
random
import
sys
from
PIL
import
Image
,
ImageDraw
,
ImageFont
from
PIL
import
Image
,
ImageDraw
,
ImageFont
text
=
[
"Mudah Diajukan
\n
Pengisian Data Tidak Rumit"
,
"Tidak bisa menyelesaikan masalah?
\n
Khawatir tentang masalah pendanaan?"
,
"Pinjaman Dana Santai
\n
Cepat Masuk dalam Rekening"
,
"Isi informasi dengan mudah dan
\n
keluar dari hutan dengan cepat"
,
"Memberikan anda layanan
\n
pinjaman berkualitas"
,
"Membantu Anda mengatasi
\n
kesulitan keuangan"
,
"Aliran Dana Untuk Anda
\n
Uangmu Tercukupi Di Sini"
,
"Pinjaman Semakin Nyaman
\n
Kangan Ragu! Unduh APPnya"
,
"Ambil Keberuntungan Kamu
\n
Bersama Kami Duitmu Beres"
,
"Membantu Anda keluar dari masalah
\n
dan menyelesaikan kesulitan keuangan"
,
"Hadir Utk Area Indonesia
\n
Layanan Pelanggan Sapa Ramah"
]
text
=
[
"Mudah Diajukan
\n
Pengisian Data Tidak Rumit"
,
\
def
draw_bg
(
bg_path
,
logo_path
,
top_path
,
output
):
"Tidak bisa menyelesaikan masalah?
\n
Khawatir tentang masalah pendanaan?"
,
\
"Pinjaman Dana Santai
\n
Cepat Masuk dalam Rekening"
,
\
"Isi informasi dengan mudah dan
\n
keluar dari hutan dengan cepat"
,
\
"Memberikan anda layanan
\n
pinjaman berkualitas"
,
\
"Membantu Anda mengatasi
\n
kesulitan keuangan"
,
\
"Aliran Dana Untuk Anda
\n
Uangmu Tercukupi Di Sini"
,
\
"Pinjaman Semakin Nyaman
\n
Kangan Ragu! Unduh APPnya"
,
\
"Ambil Keberuntungan Kamu
\n
Bersama Kami Duitmu Beres"
,
\
"Membantu Anda keluar dari masalah
\
dan menyelesaikan kesulitan keuangan"
,
\
"Hadir Utk Area Indonesia
\n
Layanan Pelanggan Sapa Ramah"
]
def
draw_bg
(
bg_path
,
logo_path
,
top_path
,
output
):
img_bg
=
Image
.
open
(
bg_path
)
img_bg
=
Image
.
open
(
bg_path
)
img_logo
=
Image
.
open
(
logo_path
)
img_logo
=
Image
.
open
(
logo_path
)
img_top
=
Image
.
open
(
top_path
)
img_top
=
Image
.
open
(
top_path
)
text_h
=
random
.
randint
(
0
,
1400
)
text_h
=
random
.
randint
(
0
,
1400
)
logo_h
=
random
.
randint
(
0
,
1400
)
logo_h
=
random
.
randint
(
0
,
1400
)
top_h
=
random
.
randint
(
0
,
1400
)
top_h
=
random
.
randint
(
0
,
1400
)
text_index
=
random
.
randint
(
0
,
len
(
text
)
-
1
)
text_index
=
random
.
randint
(
0
,
len
(
text
)
-
1
)
while
abs
(
logo_h
-
text_h
)
<
400
or
abs
(
top_h
-
text_h
)
<
400
:
while
abs
(
logo_h
-
text_h
)
<
400
or
abs
(
top_h
-
text_h
)
<
400
:
logo_h
=
random
.
randint
(
0
,
1400
)
logo_h
=
random
.
randint
(
0
,
1400
)
top_h
=
random
.
randint
(
0
,
1400
)
top_h
=
random
.
randint
(
0
,
1400
)
# 添加背景
# 添加背景
new_img
=
Image
.
new
(
'RGBA'
,
(
img_bg
.
size
[
0
]
*
2
,
img_bg
.
size
[
1
]),
(
0
,
0
,
0
,
0
))
new_img
=
Image
.
new
(
'RGBA'
,
(
img_bg
.
size
[
0
]
*
2
,
img_bg
.
size
[
1
]),
(
0
,
0
,
0
,
0
))
new_img
.
paste
(
img_bg
,
(
0
,
0
))
new_img
.
paste
(
img_bg
,
(
0
,
0
))
new_img
.
paste
(
img_bg
,
(
img_bg
.
size
[
0
],
0
))
new_img
.
paste
(
img_bg
,
(
img_bg
.
size
[
0
],
0
))
img_logo
=
img_logo
.
resize
((
300
,
300
),
Image
.
ANTIALIAS
)
img_logo
=
img_logo
.
resize
((
300
,
300
),
Image
.
ANTIALIAS
)
img_top
=
img_top
.
resize
((
700
,
342
),
Image
.
ANTIALIAS
)
img_top
=
img_top
.
resize
((
700
,
342
),
Image
.
ANTIALIAS
)
#logo随机位置
#
logo随机位置
new_img
.
paste
(
img_logo
,
(
random
.
randint
(
0
,
700
),
logo_h
),
mask
=
img_logo
)
new_img
.
paste
(
img_logo
,
(
random
.
randint
(
0
,
700
),
logo_h
),
mask
=
img_logo
)
new_img
.
paste
(
img_top
,
(
1080
,
top_h
))
new_img
.
paste
(
img_top
,
(
1080
,
top_h
))
# 字体随机大小
# 字体随机大小
font_size
=
random
.
randint
(
120
,
180
)
font_size
=
random
.
randint
(
120
,
180
)
...
@@ -50,15 +51,14 @@ def draw_bg(bg_path,logo_path,top_path,output):
...
@@ -50,15 +51,14 @@ def draw_bg(bg_path,logo_path,top_path,output):
img_text
=
Image
.
new
(
'RGBA'
,
new_img
.
size
,
(
255
,
255
,
255
,
0
))
img_text
=
Image
.
new
(
'RGBA'
,
new_img
.
size
,
(
255
,
255
,
255
,
0
))
image_draw
=
ImageDraw
.
Draw
(
img_text
)
image_draw
=
ImageDraw
.
Draw
(
img_text
)
image_draw
.
text
((
random
.
randint
(
0
,
300
),
text_h
),
text
[
text_index
],
font
=
font
,
fill
=
"#FFFFFF"
)
image_draw
.
text
((
random
.
randint
(
0
,
300
),
text_h
),
text
[
text_index
],
font
=
font
,
fill
=
"#FFFFFF"
)
bg_with_text
=
Image
.
alpha_composite
(
new_img
,
img_text
)
bg_with_text
=
Image
.
alpha_composite
(
new_img
,
img_text
)
# 裁切图片
# 裁切图片
screen1
=
bg_with_text
.
crop
((
0
,
0
,
img_bg
.
size
[
0
],
img_bg
.
size
[
1
]))
screen1
=
bg_with_text
.
crop
((
0
,
0
,
img_bg
.
size
[
0
],
img_bg
.
size
[
1
]))
screen2
=
bg_with_text
.
crop
((
img_bg
.
size
[
0
],
0
,
img_bg
.
size
[
0
]
*
2
,
img_bg
.
size
[
1
]))
screen2
=
bg_with_text
.
crop
((
img_bg
.
size
[
0
],
0
,
img_bg
.
size
[
0
]
*
2
,
img_bg
.
size
[
1
]))
screen1
.
save
(
output
+
"screen1.png"
,
"PNG"
)
screen1
.
save
(
output
+
"screen1.png"
,
"PNG"
)
screen2
.
save
(
output
+
"screen2.png"
,
"PNG"
)
screen2
.
save
(
output
+
"screen2.png"
,
"PNG"
)
draw_bg
(
sys
.
argv
[
1
],
sys
.
argv
[
2
],
sys
.
argv
[
3
],
sys
.
argv
[
4
])
draw_bg
(
sys
.
argv
[
1
],
sys
.
argv
[
2
],
sys
.
argv
[
3
],
sys
.
argv
[
4
])
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