Allow for PNG

This commit is contained in:
2023-05-16 03:44:34 -04:00
parent b7d83178f7
commit b9b45969f3

View File

@@ -811,19 +811,22 @@ async def convert_file(
for image in images:
# *** Part 1: *** Convert the file and save the file to tmp and then save the hashed file to hosted_files directory.
save_path = os.path.join(hosted_tmp_convert_file_path, 'converted_3840px_lossy_90q.webp')
# save_path = os.path.join(hosted_tmp_convert_file_path, 'converted_3840px_lossless_100q.webp')
if to_type == 'webp':
save_path = os.path.join(hosted_tmp_convert_file_path, 'converted_3840px_lossy_90q.webp')
# save_path = os.path.join(hosted_tmp_convert_file_path, 'converted_3840px_lossless_100q.webp')
# image.save('testing_2625px_9.png', compress_level=9)
# Lossy WebP takes about 25% of the time as WebP lossless compression with 100 level effort
# .46 seconds vs 2.1 seconds with example PDF
# Lossy WebP takes about 25% of the time as WebP lossless compression with 100 level effort
# .46 seconds vs 2.1 seconds with example PDF
# image.save('testing_2625px_80q.webp', quality=80) # default
# timer_2a_start = timer()
image.save(save_path, lossless=False, quality=90) # default quality is 80
# timer_2a_end = timer()
# print( round((timer_2a_end - timer_2a_start), 8) )
# image.save('testing_2625px_80q.webp', quality=80) # default
# timer_2a_start = timer()
image.save(save_path, lossless=False, quality=90) # default quality is 80
# timer_2a_end = timer()
# print( round((timer_2a_end - timer_2a_start), 8) )
elif to_type == 'png':
save_path = os.path.join(hosted_tmp_convert_file_path, 'converted_3840px_lossless_9.png')
image.save(save_path, compress_level=9)
else: return False
# timer_2b_start = timer()
# image.save('testing_2160px_lossless_100q.webp', lossless=True, quality=100) # quality is level of effort