bcmd 0.5.7__tar.gz → 0.5.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of bcmd might be problematic. Click here for more details.
- {bcmd-0.5.7 → bcmd-0.5.9}/PKG-INFO +2 -1
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/main.py +1 -1
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/tasks/__init__.py +1 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/tasks/image.py +9 -2
- bcmd-0.5.9/bcmd/tasks/pdf.py +43 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd.egg-info/PKG-INFO +2 -1
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd.egg-info/SOURCES.txt +1 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd.egg-info/requires.txt +1 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/pyproject.toml +3 -1
- {bcmd-0.5.7 → bcmd-0.5.9}/MANIFEST.in +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/README.md +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/__init__.py +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/common/__init__.py +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/common/func.py +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/common/password.py +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/resources/project/.gitignore +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/resources/project/.vscode/launch.json +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/resources/project/.vscode/settings.json +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/resources/project/.vscode/tasks.json +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/resources/project/main.py +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/tasks/bin.py +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/tasks/code.py +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/tasks/crypto.py +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/tasks/debian.py +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/tasks/download.py +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/tasks/json.py +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/tasks/lib.py +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/tasks/math.py +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/tasks/mirror.py +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/tasks/project.py +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/tasks/proxy.py +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/tasks/time.py +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/tasks/upgrade.py +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd/tasks/venv.py +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd.egg-info/dependency_links.txt +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd.egg-info/entry_points.txt +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/bcmd.egg-info/top_level.txt +0 -0
- {bcmd-0.5.7 → bcmd-0.5.9}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: bcmd
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.9
|
|
4
4
|
Summary: Commands for Beni
|
|
5
5
|
Author-email: Beni Mang <benimang@126.com>
|
|
6
6
|
Maintainer-email: Beni Mang <benimang@126.com>
|
|
@@ -13,6 +13,7 @@ Requires-Dist: pathspec
|
|
|
13
13
|
Requires-Dist: pillow
|
|
14
14
|
Requires-Dist: prettytable
|
|
15
15
|
Requires-Dist: psutil
|
|
16
|
+
Requires-Dist: pymupdf
|
|
16
17
|
Requires-Dist: qiniu
|
|
17
18
|
Requires-Dist: twine
|
|
18
19
|
Requires-Dist: typer
|
|
@@ -65,7 +65,7 @@ async def convert(
|
|
|
65
65
|
@syncCall
|
|
66
66
|
async def tiny(
|
|
67
67
|
path: Path = typer.Option(None, '--path', help='指定目录或具体图片文件,默认当前目录'),
|
|
68
|
-
|
|
68
|
+
optimization: int = typer.Option(25, '--optimization', help='指定优化大小,如果没有达到优化效果就不处理,单位:%,默认25'),
|
|
69
69
|
isKeepOriginal: bool = typer.Option(False, '--keep-original', help='保留原始图片'),
|
|
70
70
|
):
|
|
71
71
|
|
|
@@ -75,6 +75,9 @@ async def tiny(
|
|
|
75
75
|
'q8YLcvrXVW2NYcr5mMyzQhsSHF4j7gny',
|
|
76
76
|
]
|
|
77
77
|
random.shuffle(keyList)
|
|
78
|
+
|
|
79
|
+
btask.assertTrue(0 < optimization < 100, '优化大小必须在0-100之间')
|
|
80
|
+
compression = 100 - optimization
|
|
78
81
|
await block.setLimit(_TinyFile.runTiny, len(keyList))
|
|
79
82
|
|
|
80
83
|
# 整理文件列表
|
|
@@ -103,7 +106,11 @@ async def tiny(
|
|
|
103
106
|
pass
|
|
104
107
|
else:
|
|
105
108
|
# 要忽略掉的文件
|
|
106
|
-
|
|
109
|
+
if file.isTiny:
|
|
110
|
+
bcolor.printYellow(f'{file.file}({file.compression - 100:.2f}% / 已压缩 / {file.getSizeDisplay()})')
|
|
111
|
+
else:
|
|
112
|
+
bcolor.printMagenta(f'{file.file}({file.compression - 100:.2f}% / 不处理 / {file.getSizeDisplay()})')
|
|
113
|
+
|
|
107
114
|
fileList[i] = Null
|
|
108
115
|
fileList = [x for x in fileList if x]
|
|
109
116
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from typing import Final
|
|
3
|
+
|
|
4
|
+
import fitz
|
|
5
|
+
import typer
|
|
6
|
+
from beni import bcolor, bfile, btask
|
|
7
|
+
from beni.bfunc import syncCall
|
|
8
|
+
|
|
9
|
+
app: Final = btask.newSubApp('PDF相关')
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@app.command()
|
|
13
|
+
@syncCall
|
|
14
|
+
async def output_images(
|
|
15
|
+
target: Path = typer.Option(Path.cwd(), '--target', help='PDF文件路径或多个PDF文件所在的目录'),
|
|
16
|
+
):
|
|
17
|
+
'保存 PDF 文件里面的图片'
|
|
18
|
+
|
|
19
|
+
# 列出需要检查的PDF文件
|
|
20
|
+
pdfFileList: list[Path] = []
|
|
21
|
+
if target.is_dir():
|
|
22
|
+
pdfFileList = list(target.glob('*.pdf'))
|
|
23
|
+
elif target.is_file():
|
|
24
|
+
pdfFileList = [target]
|
|
25
|
+
else:
|
|
26
|
+
raise ValueError("目标路径不存在")
|
|
27
|
+
|
|
28
|
+
for pdf_file in pdfFileList:
|
|
29
|
+
pdf_document = fitz.open(pdf_file)
|
|
30
|
+
output_dir = pdf_file.with_name(pdf_file.stem + '-PDF图片文件')
|
|
31
|
+
for page_num in range(len(pdf_document)):
|
|
32
|
+
page = pdf_document.load_page(page_num)
|
|
33
|
+
images = page.get_images(full=True)
|
|
34
|
+
for img_index, img in enumerate(images):
|
|
35
|
+
xref = img[0]
|
|
36
|
+
base_image = pdf_document.extract_image(xref)
|
|
37
|
+
image_bytes = base_image["image"]
|
|
38
|
+
image_ext = base_image["ext"]
|
|
39
|
+
image_filename = f"page{page_num + 1}_img{img_index + 1}.{image_ext}"
|
|
40
|
+
image_path = output_dir / image_filename
|
|
41
|
+
output_dir.mkdir(exist_ok=True)
|
|
42
|
+
bcolor.printGreen(image_path)
|
|
43
|
+
await bfile.writeBytes(image_path, image_bytes)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: bcmd
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.9
|
|
4
4
|
Summary: Commands for Beni
|
|
5
5
|
Author-email: Beni Mang <benimang@126.com>
|
|
6
6
|
Maintainer-email: Beni Mang <benimang@126.com>
|
|
@@ -13,6 +13,7 @@ Requires-Dist: pathspec
|
|
|
13
13
|
Requires-Dist: pillow
|
|
14
14
|
Requires-Dist: prettytable
|
|
15
15
|
Requires-Dist: psutil
|
|
16
|
+
Requires-Dist: pymupdf
|
|
16
17
|
Requires-Dist: qiniu
|
|
17
18
|
Requires-Dist: twine
|
|
18
19
|
Requires-Dist: typer
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
[project]
|
|
5
5
|
name = 'bcmd'
|
|
6
|
-
version = '0.5.
|
|
6
|
+
version = '0.5.9'
|
|
7
7
|
description = 'Commands for Beni'
|
|
8
8
|
requires-python = '>=3.10'
|
|
9
9
|
keywords = ['benimang', 'beni', 'bcmd']
|
|
@@ -19,9 +19,11 @@ dependencies = [
|
|
|
19
19
|
'pillow',
|
|
20
20
|
'prettytable',
|
|
21
21
|
'psutil',
|
|
22
|
+
'pymupdf',
|
|
22
23
|
'qiniu',
|
|
23
24
|
'twine',
|
|
24
25
|
'typer',
|
|
26
|
+
# 'img2pdf',
|
|
25
27
|
# 'pytest',
|
|
26
28
|
# 'pytest-asyncio',
|
|
27
29
|
# 'pytest-order',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|