mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-20 23:26:42 +00:00
third time's the charm
This commit is contained in:
parent
71bc35224b
commit
0e28b79089
1 changed files with 43 additions and 36 deletions
|
@ -145,6 +145,7 @@ def generate_instance_layer(content_width):
|
||||||
|
|
||||||
|
|
||||||
def generate_rating_layer(rating, content_width):
|
def generate_rating_layer(rating, content_width):
|
||||||
|
try:
|
||||||
icon_star_full = Image.open(
|
icon_star_full = Image.open(
|
||||||
os.path.join(settings.STATIC_ROOT, "images/icons/star-full.png")
|
os.path.join(settings.STATIC_ROOT, "images/icons/star-full.png")
|
||||||
)
|
)
|
||||||
|
@ -161,7 +162,9 @@ def generate_rating_layer(rating, content_width):
|
||||||
rating_layer_base = Image.new(
|
rating_layer_base = Image.new(
|
||||||
"RGBA", (content_width, icon_size), color=TRANSPARENT_COLOR
|
"RGBA", (content_width, icon_size), color=TRANSPARENT_COLOR
|
||||||
)
|
)
|
||||||
rating_layer_color = Image.new("RGBA", (content_width, icon_size), color=TEXT_COLOR)
|
rating_layer_color = Image.new(
|
||||||
|
"RGBA", (content_width, icon_size), color=TEXT_COLOR
|
||||||
|
)
|
||||||
rating_layer_mask = Image.new(
|
rating_layer_mask = Image.new(
|
||||||
"RGBA", (content_width, icon_size), color=TRANSPARENT_COLOR
|
"RGBA", (content_width, icon_size), color=TRANSPARENT_COLOR
|
||||||
)
|
)
|
||||||
|
@ -188,6 +191,8 @@ def generate_rating_layer(rating, content_width):
|
||||||
)
|
)
|
||||||
|
|
||||||
return rating_layer_composite
|
return rating_layer_composite
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def generate_default_inner_img():
|
def generate_default_inner_img():
|
||||||
|
@ -273,6 +278,8 @@ def generate_preview_image(
|
||||||
# Add some more margin
|
# Add some more margin
|
||||||
contents_composite_y = contents_composite_y + gutter
|
contents_composite_y = contents_composite_y + gutter
|
||||||
rating_layer = generate_rating_layer(rating, content_width)
|
rating_layer = generate_rating_layer(rating, content_width)
|
||||||
|
|
||||||
|
if rating_layer:
|
||||||
contents_layer.alpha_composite(rating_layer, (0, contents_composite_y))
|
contents_layer.alpha_composite(rating_layer, (0, contents_composite_y))
|
||||||
contents_composite_y = contents_composite_y + rating_layer.height + gutter
|
contents_composite_y = contents_composite_y + rating_layer.height + gutter
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue