diff --git a/aperisolve/analyzers/decomposer.py b/aperisolve/analyzers/decomposer.py index b923fed..e6440d3 100644 --- a/aperisolve/analyzers/decomposer.py +++ b/aperisolve/analyzers/decomposer.py @@ -11,6 +11,12 @@ from .utils import update_data def analyze_decomposer(input_img: Path, output_dir: Path) -> None: """Analyze an image submission using bits decomposition.""" img = Image.open(input_img) + converted = False + + if img.mode == "P": + img = img.convert("RGB") + converted = True + img_np = np.array(img) # Handle grayscale, RGB, RGBA, etc. @@ -58,12 +64,15 @@ def analyze_decomposer(input_img: Path, output_dir: Path) -> None: bit_img.save(out_path) image_json[channel_label] = channel_json - update_data( - output_dir, - { - "decomposer": { - "status": "ok", - "images": image_json, - } - }, - ) + output = { + "decomposer": { + "status": "ok", + "images": image_json, + } + } + if converted: + output["decomposer"][ + "note" + ] = "Image contains a color palette and was converted to RGB for processing." + + update_data(output_dir, output) diff --git a/aperisolve/analyzers/image_resize.py b/aperisolve/analyzers/image_resize.py index 4e35e15..bf30897 100644 --- a/aperisolve/analyzers/image_resize.py +++ b/aperisolve/analyzers/image_resize.py @@ -147,12 +147,12 @@ def analyze_image_resize(input_img: Path, output_dir: Path) -> None: logs.append(f"Target CRC found: 0x{png.crc:08x}") if png.crc == png.compute_crc(): - logs.append( + note = ( f"PNG is already valid with dimensions {png.width}x{png.height} " f"and crc 0x{png.crc:08x}." ) output_no_compute: dict[str, Any] = { - "image_resize": {"status": "ok", "output": logs} + "image_resize": {"status": "ok", "note": note} } update_data(output_dir, output_no_compute) return diff --git a/aperisolve/static/js/aperisolve.js b/aperisolve/static/js/aperisolve.js index a093ce7..54ecf94 100644 --- a/aperisolve/static/js/aperisolve.js +++ b/aperisolve/static/js/aperisolve.js @@ -327,9 +327,15 @@ function parseResult(result) { result[tool]["download"] )}" target="_blank" class="btn btn-primary mt-2"> Download file`; } - } else if (result[tool]["status"] === "error") { + } + + if (result[tool]["error"] && (/[^\s]/.test(result[tool]["error"]))) { showDanger(result[tool]["error"]); } + + if (result[tool]["note"] && (/[^\s]/.test(result[tool]["note"]))) { + showInfo(result[tool]["note"]); + } } }