Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
imgyaso
提交
7b80717b
I
imgyaso
项目概览
OpenDocCN
/
imgyaso
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
imgyaso
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
7b80717b
编写于
4月 29, 2020
作者:
W
wizardforcel
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update __init__
上级
72fd3ea6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
3 deletion
+14
-3
imgyaso/__init__.py
imgyaso/__init__.py
+6
-0
imgyaso/__main__.py
imgyaso/__main__.py
+2
-2
imgyaso/quant.py
imgyaso/quant.py
+6
-1
未找到文件。
imgyaso/__init__.py
浏览文件 @
7b80717b
...
...
@@ -3,6 +3,12 @@
"""ImgYaso
https://github.com/apachecn/imgyaso"""
from
.adathres
import
adathres_bts
,
adathres
from
.dither
import
grid_bts
,
grid
,
noise_bts
,
noise
from
.quant
import
pngquant_bts
,
pngquant
from
.trunc
import
trunc_bts
,
trunc
from
.util
import
*
__author__
=
"ApacheCN"
__email__
=
"apachecn@163.com"
__license__
=
"SATA"
...
...
imgyaso/__main__.py
浏览文件 @
7b80717b
...
...
@@ -3,7 +3,7 @@ from os import path
from
.
import
__version__
from
.adathres
import
adathres_bts
from
.dither
import
grid_bts
,
noise_bts
from
.quant
import
pngquant
from
.quant
import
pngquant
_bts
from
.trunc
import
trunc_bts
from
.util
import
*
...
...
@@ -34,7 +34,7 @@ def main():
elif
args
.
mode
==
'trunc'
:
img
=
trunc_bts
(
img
,
args
.
colors
)
elif
args
.
mode
==
'quant'
:
img
=
pngquant
(
img
,
args
.
colors
)
img
=
pngquant
_bts
(
img
,
args
.
colors
)
elif
args
.
mode
==
'thres'
:
img
=
adathres_bts
(
img
)
...
...
imgyaso/quant.py
浏览文件 @
7b80717b
...
...
@@ -7,6 +7,11 @@ import sys
from
.util
import
*
def
pngquant
(
img
,
ncolors
=
8
):
img
=
bytes
(
cv2
.
imencode
(
'.png'
,
img
,
[
cv2
.
IMWRITE_PNG_COMPRESSION
,
9
])[
1
])
img
=
pngquant_bts
(
img
,
ncolors
)
return
cv2
.
imdecode
(
np
.
frombuffer
(
img
,
np
.
uint8
),
cv2
.
IMREAD_UNCHANGED
)
def
pngquant_bts
(
img
,
ncolors
=
8
):
img
=
conv2png
(
img
)
fname
=
path
.
join
(
tempfile
.
gettempdir
(),
...
...
@@ -27,7 +32,7 @@ def pngquant(img, ncolors=8):
def
main
():
fname
=
sys
.
argv
[
1
]
img
=
open
(
fname
,
'rb'
).
read
()
img
=
pngquant
(
img
)
img
=
pngquant
_bts
(
img
)
with
open
(
fname
,
'wb'
)
as
f
:
f
.
write
(
img
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录