mirror of
https://github.com/Hopiu/NDPI-to-DZI.git
synced 2026-03-16 22:00:24 +00:00
Add progress bar for NDPI to DZI conversion and update .gitignore
This commit is contained in:
parent
013af37f66
commit
100931dce1
2 changed files with 22 additions and 7 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -160,3 +160,5 @@ cython_debug/
|
|||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
|
||||
output/
|
||||
|
|
@ -24,14 +24,27 @@ def convert_ndpi_to_dzi(
|
|||
except pyvips.Error as exc:
|
||||
raise click.ClickException(f"Failed to open '{input_ndpi}': {exc}") from exc
|
||||
|
||||
image.set_progress(True)
|
||||
|
||||
try:
|
||||
image.dzsave(
|
||||
output,
|
||||
suffix=f".jpeg[Q={quality}]",
|
||||
tile_size=tile_size,
|
||||
overlap=overlap,
|
||||
depth=depth,
|
||||
)
|
||||
with click.progressbar(length=100, label="Converting") as bar:
|
||||
last_percent = [0]
|
||||
|
||||
def eval_cb(_image, progress):
|
||||
delta = progress.percent - last_percent[0]
|
||||
if delta > 0:
|
||||
bar.update(delta)
|
||||
last_percent[0] = progress.percent
|
||||
|
||||
image.signal_connect("eval", eval_cb)
|
||||
|
||||
image.dzsave(
|
||||
output,
|
||||
suffix=f".jpeg[Q={quality}]",
|
||||
tile_size=tile_size,
|
||||
overlap=overlap,
|
||||
depth=depth,
|
||||
)
|
||||
except pyvips.Error as exc:
|
||||
raise click.ClickException(f"Failed to save DZI: {exc}") from exc
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue