This commit is contained in:
mike
2026-06-28 00:51:07 +02:00
parent 19e0656ccb
commit 3f91694491
5 changed files with 341 additions and 96 deletions

View File

@@ -3496,6 +3496,7 @@ def autocrop_image(filename: str):
cmin, cmax = np.where(cols)[0][[0, -1]]
cropped = img.crop((cmin, rmin, cmax + 1, rmax + 1))
cropped.save(path, format="PNG")
_invalidate_static()
return {"status": "success", "filename": filename, "box": [int(cmin), int(rmin), int(cmax+1), int(rmax+1)]}
@@ -3558,8 +3559,7 @@ def manual_crop_image(filename: str, req: CropRequest):
cropped = img.crop((x1, y1, x2, y2))
fmt = "PNG" if path.lower().endswith(".png") else "JPEG"
cropped.save(path, format=fmt)
if req.as_copy:
_invalidate_static()
_invalidate_static()
return {"status": "success", "filename": filename, "new_filename": new_filename,
"new_url": f"/output/{new_filename}", "as_copy": req.as_copy,
"box": [x1, y1, x2, y2]}
@@ -3679,8 +3679,7 @@ def pad_image(filename: str, req: PadRequest):
if req.fill == "transparent":
fmt = "PNG" # JPEG cannot store alpha
padded.save(path, format=fmt)
if req.as_copy:
_invalidate_static()
_invalidate_static()
return {
"status": "success", "filename": filename, "new_filename": new_filename,
"new_url": f"/output/{new_filename}", "as_copy": req.as_copy,
@@ -3712,6 +3711,7 @@ def rotate_image(filename: str, req: RotateRequest):
img = Image.open(path).transpose(cw_to_transpose[deg])
fmt = "PNG" if path.lower().endswith(".png") else "JPEG"
img.save(path, format=fmt)
_invalidate_static()
return {"status": "success", "filename": filename, "degrees": deg}