try except added for fighter country img

This commit is contained in:
Justin 2023-04-25 18:52:10 +08:00 committed by GitHub
parent 23afc5317b
commit 4e7d568ee5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2827,9 +2827,12 @@ class StockTicker():
max_fighter1_pic = max(fighter1_img.size[0], name1_img.size[0], record1_img.size[0]) max_fighter1_pic = max(fighter1_img.size[0], name1_img.size[0], record1_img.size[0])
draw = ImageDraw.Draw(img, "RGBA") draw = ImageDraw.Draw(img, "RGBA")
img.paste(fighter1_img, (x_offset + int(max_fighter1_pic/2) - int(fighter1_img.size[0]/2), 0), mask=fighter1_img) img.paste(fighter1_img, (x_offset + int(max_fighter1_pic/2) - int(fighter1_img.size[0]/2), 0), mask=fighter1_img)
country1_img = Image.open('logos/ufc_countries/{}'.format(fight['fighter1country'].split('/')[-1].split('&')[0])) try:
country1_img.thumbnail((9000,12)) country1_img = Image.open('logos/ufc_countries/{}'.format(fight['fighter1country'].split('/')[-1].split('&')[0]))
img.paste(country1_img,(x_offset, 0)) country1_img.thumbnail((9000,12))
img.paste(country1_img,(x_offset, 0))
except:
pass
draw.rectangle([(x_offset,32),(x_offset + max(name1_img.size[0],record1_img.size[0])-4,21)], fill=(5,5,5,200)) draw.rectangle([(x_offset,32),(x_offset + max(name1_img.size[0],record1_img.size[0])-4,21)], fill=(5,5,5,200))
@ -2895,10 +2898,12 @@ class StockTicker():
draw.text((widest + int(weight_img.size[0]/2) + 2,0), 'DRAW', fill=(80,80,80),font=extra_small_font) draw.text((widest + int(weight_img.size[0]/2) + 2,0), 'DRAW', fill=(80,80,80),font=extra_small_font)
else: else:
draw.text((widest + int(weight_img.size[0]/2) + 2,0), 'LOSS', fill=(255,0,0),font=extra_small_font) draw.text((widest + int(weight_img.size[0]/2) + 2,0), 'LOSS', fill=(255,0,0),font=extra_small_font)
try:
country2_img = Image.open('logos/ufc_countries/{}'.format(fight['fighter2country'].split('/')[-1].split('&')[0])) country2_img = Image.open('logos/ufc_countries/{}'.format(fight['fighter2country'].split('/')[-1].split('&')[0]))
country2_img.thumbnail((9000,12)) country2_img.thumbnail((9000,12))
img.paste(country2_img,(x_offset-country2_img.size[0]-25, 0)) img.paste(country2_img,(x_offset-country2_img.size[0]-25, 0))
except:
pass
except: except:
pass pass