mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 09:14:27 +03:00
Apply suggestions from code review
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
This commit is contained in:
parent
af924a1f96
commit
52ac725ae0
|
@ -409,7 +409,7 @@ Using the ImageSequence Iterator class
|
|||
Batch processing with Pathlib
|
||||
-----------------------------
|
||||
|
||||
This example uses PIL togehter with pathlib, in order to reduce the quality of all png images in a folder
|
||||
This example uses PIL together with pathlib, in order to reduce the quality of all png images in a folder
|
||||
|
||||
::
|
||||
|
||||
|
@ -419,13 +419,13 @@ This example uses PIL togehter with pathlib, in order to reduce the quality of a
|
|||
|
||||
def compressImg(filepath, verbose=False):
|
||||
file = filepath.stem
|
||||
img = Image.open(filepath)
|
||||
if img.mode != 'RGB':
|
||||
img = img.convert('RGB')
|
||||
img.save(file + ".jpg",
|
||||
"JPEG",
|
||||
optimize=True,
|
||||
quality=80)
|
||||
with Image.open(filepath) as img:
|
||||
if img.mode != 'RGB':
|
||||
img = img.convert('RGB')
|
||||
img.save(file + ".jpg",
|
||||
"JPEG",
|
||||
optimize=True,
|
||||
quality=80)
|
||||
return
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user