Skip to content

Commit 2ea0e63

Browse files
authored
[https://nvbugs/6064029][perf] Use fast PNG compression for visual gen serving (#13074)
Signed-off-by: Kanghwan Jang <kanghwanj@nvidia.com> Signed-off-by: Kanghwan Jang <861393+karljang@users.noreply.github.com>
1 parent 319ad64 commit 2ea0e63

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

tensorrt_llm/serve/media_storage.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ def _save_pil_image(
604604
output: Any, # Can be path string or BytesIO
605605
format: str,
606606
quality: int,
607+
png_compress_level: int = 1,
607608
):
608609
"""Save PIL Image to file or buffer.
609610
@@ -612,6 +613,8 @@ def _save_pil_image(
612613
output: Output path (str) or BytesIO buffer
613614
format: Image format (PNG, JPEG, WEBP)
614615
quality: Quality for lossy formats (1-100)
616+
png_compress_level: PNG compression level (0-9, lower is faster).
617+
Default 1 for fast encoding; PNG is lossless at all levels.
615618
"""
616619
format_upper = format.upper()
617620

@@ -629,7 +632,7 @@ def _save_pil_image(
629632
elif format_upper == "WEBP":
630633
pil_image.save(output, format="WEBP", quality=quality)
631634
else: # PNG or default
632-
pil_image.save(output, format="PNG", optimize=True)
635+
pil_image.save(output, format="PNG", compress_level=png_compress_level)
633636

634637
@staticmethod
635638
def save_video(

0 commit comments

Comments
 (0)