Apply suggestions from code review

Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
This commit is contained in:
Jan-Hendrik Müller 2021-12-19 22:48:23 +01:00 committed by GitHub
parent 6b871fa18a
commit 36caa53fed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -502,7 +502,7 @@ in the current directory can be saved as JPEGs at reduced quality.
::
import os
import glob
from PIL import Image
@ -513,12 +513,13 @@ in the current directory can be saved as JPEGs at reduced quality.
img.save(dest_path, "JPEG", optimize=True, quality=80)
paths = glob.glob(".png")
paths = glob.glob("*.png")
for path in paths:
compress_image(path, path[:-4] + ".jpg")
Since images can also be opened from a ``Path`` from the ``pathlib`` module,
the example could be modified to use ``pathlib`` instead of ``os``.
the example could be modified to use ``pathlib`` instead of the ``glob``
module.
::