Skip to content

Commit eba792e

Browse files
SoftFevervalerii-bokhan
authored andcommitted
Add vendor option to optimize_cover_images script
* Introduced a new command-line argument `--vendor` to process images from a specific vendor subfolder. * Enhanced error handling to check for the existence of the vendor path and list available vendors if the path does not exist. * Updated help documentation to reflect the new functionality. This change improves the script's usability for users managing multiple vendor-specific cover images.
1 parent a32f9de commit eba792e

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

scripts/optimize_cover_images.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,8 @@ def main():
448448
' %(prog)s --dry-run\n'
449449
' %(prog)s --optimize\n'
450450
' %(prog)s --optimize --quality 70-85\n'
451+
' %(prog)s --vendor Custom\n'
452+
' %(prog)s --vendor Custom --optimize\n'
451453
' %(prog)s --max-size 200\n'
452454
' %(prog)s --no-resize\n'
453455
' %(prog)s --path ./custom/path --ratio 0.80\n'
@@ -466,6 +468,11 @@ def main():
466468
default='./resources/profiles',
467469
help='Base path to search for cover images (default: ./resources/profiles)'
468470
)
471+
parser.add_argument(
472+
'--vendor',
473+
type=str,
474+
help='Process only a specific vendor subfolder (e.g., "Custom")'
475+
)
469476
parser.add_argument(
470477
'--ratio',
471478
type=float,
@@ -508,14 +515,35 @@ def main():
508515
if args.dry_run:
509516
print("⚠️ DRY RUN MODE - No changes will be saved\n")
510517

518+
# Determine the search path
519+
search_path = args.path
520+
if args.vendor:
521+
search_path = os.path.join(args.path, args.vendor)
522+
print(f"🎯 Processing vendor: {args.vendor}")
523+
print(f" Path: {search_path}")
524+
525+
# Check if vendor path exists
526+
if not os.path.exists(search_path):
527+
print(f"❌ Error: Vendor path does not exist: {search_path}")
528+
print(f"\nAvailable vendors in {args.path}:")
529+
try:
530+
vendors = [d for d in os.listdir(args.path)
531+
if os.path.isdir(os.path.join(args.path, d)) and not d.startswith('.')]
532+
for vendor in sorted(vendors):
533+
print(f" - {vendor}")
534+
except Exception:
535+
pass
536+
return 1
537+
print()
538+
511539
# Determine max size (None if --no-resize is specified)
512540
max_size = None if args.no_resize else args.max_size
513541

514542
if max_size:
515543
print(f"📏 Images will be resized to max {max_size}px if larger\n")
516544

517545
stats = find_and_process_cover_images(
518-
args.path,
546+
search_path,
519547
args.ratio,
520548
args.dry_run,
521549
args.optimize,

0 commit comments

Comments
 (0)