diff --git a/app/routers/hosted_file.py b/app/routers/hosted_file.py index e46e807..d98b8c2 100644 --- a/app/routers/hosted_file.py +++ b/app/routers/hosted_file.py @@ -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