Apply suggestions from code review

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
This commit is contained in:
Jan-Hendrik Müller 2021-12-19 13:26:30 +01:00 committed by GitHub
parent 6c8ac0e700
commit cd613e6850
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -513,7 +513,7 @@ in the current directory can be saved as JPEGs at reduced quality.
img.save(dest_path, "JPEG", optimize=True, quality=80)
paths = [path for path in os.listdir(".") if path.endsWith(".png")]
paths = glob.glob(".png")
for path in paths:
compress_image(path, path[:-4] + ".jpg")
@ -524,7 +524,7 @@ the example could be modified to use ``pathlib`` instead of ``os``.
from pathlib import Path
paths = [path for path in Path.cwd().iterdir() if path.suffix == ".png"]
paths = Path(".").glob("*.png")
for path in paths:
compress_image(path, filepath.stem + ".jpg")