mirror of
				https://github.com/ae-utbm/sith.git
				synced 2025-11-03 18:43:04 +00:00 
			
		
		
		
	custom django command for promo logos
This commit is contained in:
		
							
								
								
									
										14
									
								
								core/management/commands/add_promo_logo.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								core/management/commands/add_promo_logo.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
			
		||||
from django.core.management.base import BaseCommand
 | 
			
		||||
from PIL import Image
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Command(BaseCommand):
 | 
			
		||||
    def add_arguments(self, parser):
 | 
			
		||||
        parser.add_argument("--numero", type=int)
 | 
			
		||||
        parser.add_argument("--path", type=str)
 | 
			
		||||
 | 
			
		||||
    def handle(self, *args, **options):
 | 
			
		||||
        if options["path"] and options["numero"]:
 | 
			
		||||
            im = Image.open(options["path"]).resize((120, 120)).convert("RGBA")
 | 
			
		||||
            im.save(f"core/static/core/img/promo_{options['numero']}.png", format="PNG")
 | 
			
		||||
            im.close()
 | 
			
		||||
		Reference in New Issue
	
	Block a user