Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit946d75f

Browse files
author
ex2tron
committed
添加高质量保存代码 2019年5月2日
1 parentdbc800d commit946d75f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
3+
# 2019年5月2日
4+
5+
importcv2
6+
importnumpyasnp
7+
8+
new_img=cv2.imread('lena.jpg')
9+
# new_img = np.zeros((100,100,3)) # 新建一副纯黑色图
10+
11+
# bmp
12+
cv2.imwrite('img_bmp.bmp',new_img)# 文件大小:359KB
13+
14+
# jpg 默认95%质量
15+
cv2.imwrite('img_jpg95.jpg',new_img)# 文件大小:52.3KB
16+
# jpg 20%质量
17+
cv2.imwrite('img_jpg20.jpg',new_img,[int(cv2.IMWRITE_JPEG_QUALITY),20])# 文件大小:8.01KB
18+
# jpg 100%质量
19+
cv2.imwrite('img_jpg100.jpg',new_img,[int(cv2.IMWRITE_JPEG_QUALITY),100])# 文件大小:82.5KB
20+
21+
# png 默认1压缩比
22+
cv2.imwrite('img_png1.png',new_img)# 文件大小:240KB
23+
# png 9压缩比
24+
cv2.imwrite('img_png9.png',new_img,[int(cv2.IMWRITE_PNG_COMPRESSION),9])# 文件大小:207KB
25+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp