feat: support multiple color correction inputs

This commit is contained in:
bmondream committed 2026-09-13 10:22:33 +02:00
1 parent 4df9c0116e
commit b3f9539189
1 file changed
+24 -14
+24 -14
View File
@@ -10,7 +10,7 @@
Apply a warm print color correction (less blue, slightly yellower). Apply a warm print color correction (less blue, slightly yellower).
Usage with uv (no venv, no uv pip): Usage with uv (no venv, no uv pip):
uv run warm_print.py /path/to/image.jpg uv run warm_print.py image.jpg other.jpg /path/to/more.jpg
uv reads the dependencies in the header above and installs them uv reads the dependencies in the header above and installs them
into an isolated cache on first run. into an isolated cache on first run.
@@ -83,17 +83,8 @@ def warm_correct(im: Image.Image) -> Image.Image:
return out_im return out_im
def main() -> int: def process_one(src: Path) -> Path:
if len(sys.argv) < 2: """Color-correct one image and write sibling *_warmprint file."""
print("Usage: python warm_print.py /path/to/image.jpg", file=sys.stderr)
return 2
src = Path(sys.argv[1]).expanduser().resolve()
if not src.is_file():
print(f"Not a file: {src}", file=sys.stderr)
return 1
# Same folder, same name, short suffix before the original extension.
dest = src.with_name(f"{src.stem}_warmprint{src.suffix}") dest = src.with_name(f"{src.stem}_warmprint{src.suffix}")
im = Image.open(src) im = Image.open(src)
@@ -112,8 +103,27 @@ def main() -> int:
out_im.save(dest, "JPEG", **save_kwargs) out_im.save(dest, "JPEG", **save_kwargs)
else: else:
out_im.save(dest, "PNG", **save_kwargs) out_im.save(dest, "PNG", **save_kwargs)
print(dest) return dest
return 0
def main() -> int:
if len(sys.argv) < 2:
print(
"Usage: python warm_print.py image.jpg [more.jpg ...]",
file=sys.stderr,
)
return 2
failed = 0
for raw in sys.argv[1:]:
src = Path(raw).expanduser().resolve()
if not src.is_file():
print(f"Not a file: {src}", file=sys.stderr)
failed += 1
continue
dest = process_one(src)
print(dest)
return 1 if failed else 0
if __name__ == "__main__": if __name__ == "__main__":