Fix CLI encode format detection and jpegtran -trim bug
CLI encode: - Auto-detect output format from extension (.jpg → DCT mode, .png → LSB) - Default to JPEG output for JPEG carriers (preserves DCT benefits) - Pass embed_mode and dct_output_format to encode function jpegtran fix (critical for rotation fallback): - Remove -trim flag which was dropping edge blocks and destroying stego data - Remove -perfect flag which fails on non-MCU-aligned images - Plain jpegtran without flags works correctly for lossless rotation This enables: encode → external rotation → decode to work correctly. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2136,7 +2136,7 @@ def api_tools_rotate():
|
||||
output_path = tempfile.mktemp(suffix=".jpg")
|
||||
try:
|
||||
result = subprocess.run(
|
||||
["jpegtran", "-rotate", str(rotation), "-copy", "all", "-trim",
|
||||
["jpegtran", "-rotate", str(rotation), "-copy", "all",
|
||||
"-outfile", output_path, input_path],
|
||||
capture_output=True, timeout=30
|
||||
)
|
||||
@@ -2158,7 +2158,7 @@ def api_tools_rotate():
|
||||
output_path = tempfile.mktemp(suffix=".jpg")
|
||||
try:
|
||||
result = subprocess.run(
|
||||
["jpegtran", "-flip", "horizontal", "-copy", "all", "-trim",
|
||||
["jpegtran", "-flip", "horizontal", "-copy", "all",
|
||||
"-outfile", output_path, input_path],
|
||||
capture_output=True, timeout=30
|
||||
)
|
||||
@@ -2180,7 +2180,7 @@ def api_tools_rotate():
|
||||
output_path = tempfile.mktemp(suffix=".jpg")
|
||||
try:
|
||||
result = subprocess.run(
|
||||
["jpegtran", "-flip", "vertical", "-copy", "all", "-trim",
|
||||
["jpegtran", "-flip", "vertical", "-copy", "all",
|
||||
"-outfile", output_path, input_path],
|
||||
capture_output=True, timeout=30
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user