mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-02-03 00:31:25 -08:00
generate medium sized image even when source image is small #332
This commit is contained in:
parent
d2327fd3c1
commit
deb14b73f3
1 changed files with 8 additions and 6 deletions
|
@ -340,16 +340,18 @@ def save_post(form, post: Post, type: int):
|
||||||
img = Image.open(final_place)
|
img = Image.open(final_place)
|
||||||
if '.' + img.format.lower() in allowed_extensions:
|
if '.' + img.format.lower() in allowed_extensions:
|
||||||
img = ImageOps.exif_transpose(img)
|
img = ImageOps.exif_transpose(img)
|
||||||
|
|
||||||
|
# limit full sized version to 2000px
|
||||||
img_width = img.width
|
img_width = img.width
|
||||||
img_height = img.height
|
img_height = img.height
|
||||||
img.thumbnail((2000, 2000))
|
img.thumbnail((2000, 2000))
|
||||||
img.save(final_place)
|
img.save(final_place)
|
||||||
if img.width > 512 or img.height > 512:
|
|
||||||
img.thumbnail((512, 512))
|
# medium sized version
|
||||||
img.save(final_place_medium, format="WebP", quality=93)
|
img.thumbnail((512, 512))
|
||||||
img_width = img.width
|
img.save(final_place_medium, format="WebP", quality=93)
|
||||||
img_height = img.height
|
|
||||||
# save a second, smaller, version as a thumbnail
|
# save a third, smaller, version as a thumbnail
|
||||||
img.thumbnail((170, 170))
|
img.thumbnail((170, 170))
|
||||||
img.save(final_place_thumbnail, format="WebP", quality=93)
|
img.save(final_place_thumbnail, format="WebP", quality=93)
|
||||||
thumbnail_width = img.width
|
thumbnail_width = img.width
|
||||||
|
|
Loading…
Add table
Reference in a new issue