fix 69
This commit is contained in:
@@ -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,
|
||||
{
|
||||
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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -327,9 +327,15 @@ function parseResult(result) {
|
||||
result[tool]["download"]
|
||||
)}" target="_blank" class="btn btn-primary mt-2"><i class="fa fa-download"></i> Download file</a>`;
|
||||
}
|
||||
} 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"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user