Various Attempted fixes
This commit is contained in:
@@ -80,6 +80,7 @@ def save_image_variants(
|
||||
logger.debug(f"SaveImageVariants: Resolutions: {image_resolutions}, File Type Defs: {file_type_defs.keys()}, Output Formats: 8bit={output_format_8bit}, 16bit_pri={output_format_16bit_primary}, 16bit_fall={output_format_16bit_fallback}")
|
||||
logger.debug(f"SaveImageVariants: PNG Comp: {png_compression_level}, JPG Qual: {jpg_quality}")
|
||||
logger.debug(f"SaveImageVariants: Output Tokens: {output_filename_pattern_tokens}, Output Pattern: {output_filename_pattern}")
|
||||
logger.debug(f"SaveImageVariants: Received resolution_threshold_for_jpg: {resolution_threshold_for_jpg}") # Log received threshold
|
||||
|
||||
# 2. Determine Target Bit Depth
|
||||
target_bit_depth = 8 # Default
|
||||
@@ -173,9 +174,29 @@ def save_image_variants(
|
||||
|
||||
# Determine final extension for this variant, considering JPG threshold
|
||||
final_variant_ext = current_output_ext
|
||||
if target_bit_depth == 8 and resolution_threshold_for_jpg is not None and \
|
||||
max(target_w_res, target_h_res) > resolution_threshold_for_jpg and \
|
||||
current_output_ext == 'png': # Only convert if current 8-bit is PNG
|
||||
|
||||
# --- Start JPG Threshold Logging ---
|
||||
logger.debug(f"SaveImageVariants: JPG Threshold Check for {base_map_type} {res_key}:")
|
||||
logger.debug(f" - target_bit_depth: {target_bit_depth}")
|
||||
logger.debug(f" - resolution_threshold_for_jpg: {resolution_threshold_for_jpg}")
|
||||
logger.debug(f" - target_w_res: {target_w_res}, target_h_res: {target_h_res}")
|
||||
logger.debug(f" - max(target_w_res, target_h_res): {max(target_w_res, target_h_res)}")
|
||||
logger.debug(f" - current_output_ext: {current_output_ext}")
|
||||
|
||||
cond_bit_depth = target_bit_depth == 8
|
||||
cond_threshold_not_none = resolution_threshold_for_jpg is not None
|
||||
cond_res_exceeded = False
|
||||
if cond_threshold_not_none: # Avoid comparison if threshold is None
|
||||
cond_res_exceeded = max(target_w_res, target_h_res) > resolution_threshold_for_jpg
|
||||
cond_is_png = current_output_ext == 'png'
|
||||
|
||||
logger.debug(f" - Condition (target_bit_depth == 8): {cond_bit_depth}")
|
||||
logger.debug(f" - Condition (resolution_threshold_for_jpg is not None): {cond_threshold_not_none}")
|
||||
logger.debug(f" - Condition (max(res) > threshold): {cond_res_exceeded}")
|
||||
logger.debug(f" - Condition (current_output_ext == 'png'): {cond_is_png}")
|
||||
# --- End JPG Threshold Logging ---
|
||||
|
||||
if cond_bit_depth and cond_threshold_not_none and cond_res_exceeded and cond_is_png:
|
||||
final_variant_ext = 'jpg'
|
||||
logger.info(f"SaveImageVariants: Overriding 8-bit PNG to JPG for {base_map_type} {res_key} due to resolution {max(target_w_res, target_h_res)}px > threshold {resolution_threshold_for_jpg}px.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user