Added image placeholder if cant retrieve it
This commit is contained in:
@@ -40,7 +40,10 @@ def create_image(product_id, price):
|
||||
draw.text(((width / 6) * 5 - wtext / 2, height / 2 - htext / 2), price, (0, 0, 0), font=font)
|
||||
draw.rectangle([15, 15, width - 15, height - 15], width = 15, outline="#20e163")
|
||||
# ponemos la imagen del producto en la parte izquierda y se redimensiona dependiendo de lo ancho
|
||||
product_image = Image.open(f"/app/data/images/products/{product_id}.jpg")
|
||||
try:
|
||||
product_image = Image.open(f"/app/data/images/products/{product_id}.jpg")
|
||||
except:
|
||||
product_image = Image.open(f"/app/data/images/placeholder.jpg")
|
||||
hpercent = (baseheight / float(product_image.size[1]))
|
||||
wsize = int((float(product_image.size[0]) * float(hpercent)))
|
||||
if wsize < wlimit:
|
||||
|
||||
Reference in New Issue
Block a user