From 4b0cec7d369f355d0c73d5b0df78b831cc96758c Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Thu, 4 May 2023 17:21:09 -0400 Subject: [PATCH] Finalized PDF to webp conversion. Looks good! --- app/routers/hosted_file.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/routers/hosted_file.py b/app/routers/hosted_file.py index d7c350f..e46e807 100644 --- a/app/routers/hosted_file.py +++ b/app/routers/hosted_file.py @@ -760,7 +760,7 @@ async def convert_file( commons: Common_Route_Params = Depends(common_route_params), ): - log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL + log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) account_id = commons.x_account_id # OSIT _XY7DXtc9MY (1) @@ -774,9 +774,11 @@ async def convert_file( return mk_resp(data=None, status_code=400, response=commons.response) # Need to look up file_hash for hosted_file_id + hosted_file_obj = load_hosted_file_obj(hosted_file_id=hosted_file_id) + file_hash = hosted_file_obj.hash_sha256 # file_hash = '0080f0b03144927c173694745483894a09208d9444fdaccab054493f699361be' - file_hash = '279312d1738fd3a8a2f136b48295e28664d38b18de66c55de56b8886b9454784' # G1rTLpGbzhs (5046) + # file_hash = '279312d1738fd3a8a2f136b48295e28664d38b18de66c55de56b8886b9454784' # G1rTLpGbzhs (5046) file_hash_filename = f'{file_hash}.file' hosted_files_path = settings.FILES_PATH['hosted_files_root'] @@ -798,11 +800,19 @@ async def convert_file( log.info('Creating hosted tmp convert file path') pathlib.Path(hosted_tmp_convert_file_path).mkdir(parents=True, exist_ok=True) - images = convert_from_path(full_file_path, size=(2160, None)) + # 8K 8192x4320 + # UHD 8K 7680x4320 + # 4K 4096x2160 + # UHD 4K 3840x2160 + # 2K 2048x1080 + # HD 1920x1080 + # Save as webp with 3840 size and 90 lossy quality works well for posters. Better than in the past with PNG. Higher resolution and smaller file size! -2023-05-04 + images = convert_from_path(full_file_path, size=(3840, None)) # 2160 works well 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_2160px_lossless_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') # image.save('testing_2625px_9.png', compress_level=9)