Swap optimization steps: convert to monochrome before trimming whitespace. Include uv.lock in the commit.
This commit is contained in:
+12
-12
@@ -323,18 +323,7 @@ def optimize(level):
|
|||||||
|
|
||||||
print(f"Processing {total_files} images at optimization level {level}...")
|
print(f"Processing {total_files} images at optimization level {level}...")
|
||||||
|
|
||||||
# Step 1: Always trim whitespace
|
# Step 1: Convert to monochrome if level >= 2
|
||||||
print("\nTrimming whitespace from images...")
|
|
||||||
for i, file_path in enumerate(temp_files, 1):
|
|
||||||
print(f"[{i}/{total_files}] Processing {os.path.basename(file_path)}...", end='', flush=True)
|
|
||||||
# Only optimize if this is the final step (level 1)
|
|
||||||
if trim_whitespace(file_path, is_final=(opt_level == OptimizationLevel.TRIM)):
|
|
||||||
successful['trim'] += 1
|
|
||||||
print(" ")
|
|
||||||
else:
|
|
||||||
print(" ")
|
|
||||||
|
|
||||||
# Step 2: Convert to monochrome if level >= 2
|
|
||||||
if int(opt_level) >= int(OptimizationLevel.MONOCHROME):
|
if int(opt_level) >= int(OptimizationLevel.MONOCHROME):
|
||||||
print("\nConverting to monochrome...")
|
print("\nConverting to monochrome...")
|
||||||
for i, file_path in enumerate(temp_files, 1):
|
for i, file_path in enumerate(temp_files, 1):
|
||||||
@@ -346,6 +335,17 @@ def optimize(level):
|
|||||||
else:
|
else:
|
||||||
print(" ")
|
print(" ")
|
||||||
|
|
||||||
|
# Step 2: Always trim whitespace
|
||||||
|
print("\nTrimming whitespace from images...")
|
||||||
|
for i, file_path in enumerate(temp_files, 1):
|
||||||
|
print(f"[{i}/{total_files}] Processing {os.path.basename(file_path)}...", end='', flush=True)
|
||||||
|
# Only optimize if this is the final step (level 1)
|
||||||
|
if trim_whitespace(file_path, is_final=(opt_level == OptimizationLevel.TRIM)):
|
||||||
|
successful['trim'] += 1
|
||||||
|
print(" ")
|
||||||
|
else:
|
||||||
|
print(" ")
|
||||||
|
|
||||||
# Step 3: Run optipng if level = 3
|
# Step 3: Run optipng if level = 3
|
||||||
if opt_level == OptimizationLevel.FULL:
|
if opt_level == OptimizationLevel.FULL:
|
||||||
if check_optipng_installed():
|
if check_optipng_installed():
|
||||||
|
|||||||
Reference in New Issue
Block a user