Optimize analyzer resize, Bump python version, Change compose name

This commit is contained in:
Zeecka
2025-12-09 18:24:15 +01:00
parent b97a66d072
commit e271c15b56
5 changed files with 48 additions and 43 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
FROM python:3.11-slim AS build
FROM python:3.14-slim AS build
WORKDIR /
+2 -3
View File
@@ -73,13 +73,13 @@ Here is a batch of usefull commands.
```bash
docker compose down -v # Remove volume containings results
docker compose -f docker-compose-dev.yml up # Start application in developpement mode
docker compose -f compose.dev.yml up # Start application in developpement mode
rm -rf aperisolve/results # Remove results from developpement mode
docker exec -it postgres psql -U aperiuser -d aperisolve # Get postgresql shell
docker exec -it aperisolve-web bash # Get shell in running web app
```
> Note, if you used [docker-compose-dev.yml](docker-compose-dev.yml), you must remove "results" when switching to [production docker](docker-compose.yml).
> Note, if you used [compose.dev.yml](compose.dev.yml), you must remove "results" when switching to [production docker](compose.yml).
### Code quality
@@ -94,7 +94,6 @@ GitHub CI will alert in case of failure.
## Roadmap
- [x] PngCheck
- [ ] Zsteg extract / --all --> **Download `zsteg` files** such as mp3 encoded on LSB
- [ ] Test on mobile
- [ ] i18n
+10 -4
View File
@@ -1,6 +1,7 @@
"""Image size bruteforcer for common PNG sizes."""
import zlib
import shutil
from pathlib import Path
from .utils import update_data
@@ -116,11 +117,12 @@ def analyze_image_resize(input_img: Path, output_dir: Path) -> None:
# 3. Initialize Logs
logs = []
recovered_images = []
recovered_image = None
try:
with open(input_img, "rb") as image:
f = image.read()
b = bytearray(f)
# Find IHDR start
@@ -128,6 +130,8 @@ def analyze_image_resize(input_img: Path, output_dir: Path) -> None:
if IHDR == -1:
logs.append("Failure: PNG header (IHDR) not found.")
update_data(output_dir, {"image_resize": {"status": "error", "error": "PNG header not found."}})
if extracted_dir.exists():
shutil.rmtree(extracted_dir, ignore_errors=True)
return
# Calculate Chunk Length (The 4 bytes BEFORE IHDR tag)
@@ -164,10 +168,10 @@ def analyze_image_resize(input_img: Path, output_dir: Path) -> None:
full_png_data = b[:IHDR+4] + width_bytes + height_bytes + b[IHDR+12:]
# Write the recovered file to disk
with open(output_path, "wb") as out_f:
with output_path.open("wb") as out_f:
out_f.write(full_png_data)
recovered_images.append(output_filename)
recovered_image = output_filename
break # Stop looking after finding the match
if not match_found:
@@ -178,12 +182,14 @@ def analyze_image_resize(input_img: Path, output_dir: Path) -> None:
"image_resize": { # Key name must match your module name in AperiSolve
"status": "ok",
"output": logs,
"images": recovered_images, # Tells frontend to display the image
"images": recovered_image, # Tells frontend to display the image
}
}
update_data(output_dir, output_data)
except Exception as e:
update_data(output_dir, {"image_resize": {"status": "error", "error": str(e)}})
if extracted_dir.exists():
shutil.rmtree(extracted_dir, ignore_errors=True)
return None
View File