forked from CoderWanFeng/python-office
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage.py
More file actions
84 lines (63 loc) · 2.31 KB
/
image.py
File metadata and controls
84 lines (63 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# -*- coding: UTF-8 -*-
'''
@作者 :B站/抖音/微博/小红书/公众号,都叫:程序员晚枫,微信:CoderWanFeng
@读者群 :http://www.python4office.cn/wechat-group/
@学习网站 :https://www.python-office.com
@代码日期 :2023/8/22 23:28
'''
import poimage
# @except_dec()
from office.lib.decorator_utils.instruction_url import instruction
def compress_image(input_file: str, output_file: str, quality: int):
poimage.compress_image(input_file, output_file, quality)
# @instruction
def image2gif():
poimage.image2gif()
# todo:输出文件路径
# @except_dec()
# @instruction
def add_watermark(file, mark, output_path='./', color="#eaeaea", size=30, opacity=0.35, space=200,
angle=30):
"""
给图片加水印
Args:
file: 图片位置
mark: 水印内容
output_path: 输出位置
color: 水印颜色
size: 水印大小
opacity: 不透明度,0.01~1
space: 水印间距
angle: 水印角度
Returns:
"""
poimage.add_watermark(file, mark, output_path, color, size, opacity, space, angle)
# mainImage.add_watermark(file, mark, out, color, size, opacity, space, angle)
# todo:输入文件路径
# @except_dec()
# @instruction
def img2Cartoon(path, client_api='OVALewIvPyLmiNITnceIhrYf', client_secret='rpBQH8WuXP4ldRQo5tbDkv3t0VgzwvCN'):
poimage.img2Cartoon(path, client_api, client_secret)
# mainImage.img2Cartoon(path, client_api, client_secret)
# @except_dec()
# @instruction
def down4img(url, output_path='.', output_name='down4img', type='jpg'):
poimage.down4img(url, output_path, output_name, type)
# mainImage.down4img(url, output_name, type)
# @instruction
def txt2wordcloud(filename, color="white", result_file="your_wordcloud.png"):
poimage.txt2wordcloud(filename, color, result_file)
# @instruction
def pencil4img(input_img, output_path='./', output_name='pencil4img.jpg'):
poimage.pencil4img(input_img, output_path, output_name)
# @instruction
def decode_qrcode(qrcode_path):
"""
解析二维码
:param qrcode_path: 二维码图片的路径
:return:
"""
poimage.decode_qrcode(qrcode_path)
# @instruction
def del_watermark(input_image, output_image=r'./del_water_mark.jpg'):
poimage.del_watermark(input_image, output_image)