added some comments
This commit is contained in:
@@ -27,12 +27,16 @@ except Exception as e:
|
||||
|
||||
|
||||
def compressor(file, quality, resize, size):
|
||||
# get filepath of image
|
||||
filepath = os.path.join(os.getcwd(), file)
|
||||
|
||||
# open image
|
||||
with Image.open(filepath) as image:
|
||||
# resize and compress landscape images
|
||||
if resize and image.width >= size and image.width > image.height:
|
||||
print('resize and compress: ' + file)
|
||||
print('resizing: ' + file)
|
||||
cover = resizeimage.resize_width(image, size)
|
||||
print('compressing: ' + file)
|
||||
cover.save(
|
||||
str(final_path) + '/' + 'min-' + file,
|
||||
image.format,
|
||||
@@ -40,9 +44,11 @@ def compressor(file, quality, resize, size):
|
||||
quality=quality,
|
||||
resample=Image.LANCZOS
|
||||
)
|
||||
# resize and compress portrait images
|
||||
elif resize and image.height >= size and image.height > image.width:
|
||||
print('resize and compress: ' + file)
|
||||
print('resizing: ' + file)
|
||||
cover = resizeimage.resize_height(image, size)
|
||||
print('compressing: ' + file)
|
||||
cover.save(
|
||||
str(final_path) + '/' + 'min-' + file,
|
||||
image.format,
|
||||
@@ -50,6 +56,7 @@ def compressor(file, quality, resize, size):
|
||||
quality=quality,
|
||||
resample=Image.LANCZOS
|
||||
)
|
||||
# compress images
|
||||
else:
|
||||
print('compress: ' + file)
|
||||
image.save(
|
||||
|
Reference in New Issue
Block a user