Allow for PNG

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

View File

@@ -811,11 +811,10 @@ async def convert_file(
for image in images: 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. # *** Part 1: *** Convert the file and save the file to tmp and then save the hashed file to hosted_files directory.
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_lossy_90q.webp')
# save_path = os.path.join(hosted_tmp_convert_file_path, 'converted_3840px_lossless_100q.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 # 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 # .46 seconds vs 2.1 seconds with example PDF
@@ -824,6 +823,10 @@ async def convert_file(
image.save(save_path, lossless=False, quality=90) # default quality is 80 image.save(save_path, lossless=False, quality=90) # default quality is 80
# timer_2a_end = timer() # timer_2a_end = timer()
# print( round((timer_2a_end - timer_2a_start), 8) ) # 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() # timer_2b_start = timer()
# image.save('testing_2160px_lossless_100q.webp', lossless=True, quality=100) # quality is level of effort # image.save('testing_2160px_lossless_100q.webp', lossless=True, quality=100) # quality is level of effort