Skip to content
This repository was archived by the owner on Mar 10, 2023. It is now read-only.

Commit 5cafedd

Browse files
committed
Show totals
1 parent d232cd3 commit 5cafedd

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ You can download and use it as single Windows binary, see [Releases](https://git
2929

3030
Unfortunately antiviruses [don't like packed Python executables](https://github.com/pyinstaller/pyinstaller/issues?q=is%3Aissue+virus), so expect false positives from them if you go this way. Best way is pip.
3131

32-
You will need [cjxl](https://gitlab.com/wg1/jpeg-xl/-/blob/master/doc/developing_in_windows.md) in path, for example `%USERPROFILE%\AppData\Local\Microsoft\WindowsApps`
32+
You will need [cjxl](https://gitlab.com/wg1/jpeg-xl/-/blob/master/doc/developing_in_windows.md) in path. It's best to build it using [this tool](https://github.com/m-ab-s/media-autobuild_suite) and copy to `%USERPROFILE%\AppData\Local\Microsoft\WindowsApps`
3333

3434
```cmd
3535
./makejxl.exe "c:\\Users\\username\\Pictures\\My Vacation"

makejxl.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
from typing import Iterable
99

1010
import click
11-
from termcolor import colored
1211

13-
__version__ = '0.1.0'
12+
__version__ = '0.1.1'
1413
SUPPORTED_FORMATS = ['jpeg', 'jpg', 'png', 'apng', 'gif', 'exr', 'ppm', 'pfm', 'pgx']
1514

1615

@@ -39,6 +38,9 @@ def search_files(dirpath: str, recursive: bool) -> Iterable[str]:
3938
@click.option('-r', '--recursive', is_flag=True, help='Recursive')
4039
@click.option('-s', '--speed', default='kitten', help='Speed')
4140
def main(directory, recursive=False, speed='kitten'):
41+
total = 0
42+
num = 0
43+
4244
if recursive:
4345
print('Processing recursively starting from', directory)
4446
recursive = True
@@ -53,12 +55,16 @@ def main(directory, recursive=False, speed='kitten'):
5355
for filepath in search_files(str(directory), recursive=recursive):
5456
fp = pathlib.PurePath(filepath)
5557
newpath = fp.parent.joinpath(fp.stem + '.' + 'jxl')
56-
convert_cmd = f'cjxl -s {speed} {fp} {newpath}'
58+
convert_cmd = f'cjxl --quiet -s {speed} {fp} {newpath}'
5759
conversion_return_code = run(convert_cmd, shell=True).returncode
5860
if conversion_return_code == 0:
59-
print(colored(newpath, 'green'), 'ready')
61+
saved = os.path.getsize(fp) - os.path.getsize(newpath)
62+
total += saved
63+
num += 1
64+
print(newpath, 'ready, saved', round(saved / 1024), 'KB')
6065
else:
61-
print(colored(fp, 'red'), 'error')
66+
print(fp, 'error')
67+
print('Total saved', round(total / 1024 / 1024), 'MB in', num, 'files')
6268

6369

6470
if __name__ == '__main__':

requirements.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
click~=7.1.2
2-
termcolor~=1.1.0
1+
click~=7.1.2

setup.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,15 @@
1111
long_description = fh.read()
1212

1313
install_requires = [
14-
'click>=7.1.2',
15-
'termcolor>=1.1.0'
14+
'click>=7.1.2'
1615
]
1716

1817
setuptools.setup(
1918
name="makejxl",
2019
version=makejxl.__version__,
2120
author="Evgeny Varnavskiy",
2221
author_email="[email protected]",
23-
description="This tool will bulk encode image files in given directory to [JPEG-XL]",
22+
description="This tool will bulk encode image files in given directory to JPEG-XL",
2423
long_description=long_description,
2524
long_description_content_type="text/markdown",
2625
url="https://github.com/varnav/makejxl",

0 commit comments

Comments
 (0)