Refactor compression flow with routing seam
Introduce compress_image_with_routing and compress_raster_image to prepare extensible backend routing while keeping existing behavior unchanged. Add unit test that verifies routing currently delegates to raster compressor. Co-Authored-By: Abacus.AI CLI <agent@abacus.ai>
This commit is contained in:
+37
-1
@@ -218,6 +218,42 @@ def run_compressor(
|
||||
return compressor(original, out_dir, caesium_threads, quality, min_savings)
|
||||
|
||||
|
||||
def compress_raster_image(
|
||||
compressor: Callable[..., Path | None],
|
||||
original: Path,
|
||||
out_dir: Path,
|
||||
caesium_threads: int | None,
|
||||
quality: int,
|
||||
min_savings: str,
|
||||
) -> Path | None:
|
||||
return run_compressor(
|
||||
compressor=compressor,
|
||||
original=original,
|
||||
out_dir=out_dir,
|
||||
caesium_threads=caesium_threads,
|
||||
quality=quality,
|
||||
min_savings=min_savings,
|
||||
)
|
||||
|
||||
|
||||
def compress_image_with_routing(
|
||||
compressor: Callable[..., Path | None],
|
||||
original: Path,
|
||||
out_dir: Path,
|
||||
caesium_threads: int | None,
|
||||
quality: int,
|
||||
min_savings: str,
|
||||
) -> Path | None:
|
||||
return compress_raster_image(
|
||||
compressor=compressor,
|
||||
original=original,
|
||||
out_dir=out_dir,
|
||||
caesium_threads=caesium_threads,
|
||||
quality=quality,
|
||||
min_savings=min_savings,
|
||||
)
|
||||
|
||||
|
||||
def update_relationship_targets(work_dir: Path, old_name: str, new_name: str) -> None:
|
||||
rels_namespace = "{http://schemas.openxmlformats.org/package/2006/relationships}Relationship"
|
||||
for rels_file in work_dir.rglob("*.rels"):
|
||||
@@ -321,7 +357,7 @@ def process_image_file(
|
||||
|
||||
try:
|
||||
out_sub = scratch_dir / f"img_{idx:06d}"
|
||||
caesium_out = run_compressor(
|
||||
caesium_out = compress_image_with_routing(
|
||||
compressor=compressor,
|
||||
original=img_path,
|
||||
out_dir=out_sub,
|
||||
|
||||
Reference in New Issue
Block a user