This commit is contained in:
Joachim 2021-06-19 19:44:14 +02:00
parent e251b687dc
commit 0c83882a11
2 changed files with 31 additions and 1 deletions

View file

@ -1,74 +1,99 @@
"""Generators for all the different thumbnail sizes"""
from imagekit import ImageSpec, register from imagekit import ImageSpec, register
from imagekit.processors import ResizeToFit from imagekit.processors import ResizeToFit
class BookXSmallWebp(ImageSpec): class BookXSmallWebp(ImageSpec):
"""Handles XSmall size in Webp format"""
processors = [ResizeToFit(80, 80)] processors = [ResizeToFit(80, 80)]
format = "WEBP" format = "WEBP"
options = {"quality": 95} options = {"quality": 95}
class BookXSmallJpg(ImageSpec): class BookXSmallJpg(ImageSpec):
"""Handles XSmall size in Jpeg format"""
processors = [ResizeToFit(80, 80)] processors = [ResizeToFit(80, 80)]
format = "JPEG" format = "JPEG"
options = {"quality": 95} options = {"quality": 95}
class BookSmallWebp(ImageSpec): class BookSmallWebp(ImageSpec):
"""Handles Small size in Webp format"""
processors = [ResizeToFit(100, 100)] processors = [ResizeToFit(100, 100)]
format = "WEBP" format = "WEBP"
options = {"quality": 95} options = {"quality": 95}
class BookSmallJpg(ImageSpec): class BookSmallJpg(ImageSpec):
"""Handles Small size in Jpeg format"""
processors = [ResizeToFit(100, 100)] processors = [ResizeToFit(100, 100)]
format = "JPEG" format = "JPEG"
options = {"quality": 95} options = {"quality": 95}
class BookMediumWebp(ImageSpec): class BookMediumWebp(ImageSpec):
"""Handles Medium size in Webp format"""
processors = [ResizeToFit(150, 150)] processors = [ResizeToFit(150, 150)]
format = "WEBP" format = "WEBP"
options = {"quality": 95} options = {"quality": 95}
class BookMediumJpg(ImageSpec): class BookMediumJpg(ImageSpec):
"""Handles Medium size in Jpeg format"""
processors = [ResizeToFit(150, 150)] processors = [ResizeToFit(150, 150)]
format = "JPEG" format = "JPEG"
options = {"quality": 95} options = {"quality": 95}
class BookLargeWebp(ImageSpec): class BookLargeWebp(ImageSpec):
"""Handles Large size in Webp format"""
processors = [ResizeToFit(200, 200)] processors = [ResizeToFit(200, 200)]
format = "WEBP" format = "WEBP"
options = {"quality": 95} options = {"quality": 95}
class BookLargeJpg(ImageSpec): class BookLargeJpg(ImageSpec):
"""Handles Large size in Jpeg format"""
processors = [ResizeToFit(200, 200)] processors = [ResizeToFit(200, 200)]
format = "JPEG" format = "JPEG"
options = {"quality": 95} options = {"quality": 95}
class BookXLargeWebp(ImageSpec): class BookXLargeWebp(ImageSpec):
"""Handles XLarge size in Webp format"""
processors = [ResizeToFit(250, 250)] processors = [ResizeToFit(250, 250)]
format = "WEBP" format = "WEBP"
options = {"quality": 95} options = {"quality": 95}
class BookXLargeJpg(ImageSpec): class BookXLargeJpg(ImageSpec):
"""Handles XLarge size in Jpeg format"""
processors = [ResizeToFit(250, 250)] processors = [ResizeToFit(250, 250)]
format = "JPEG" format = "JPEG"
options = {"quality": 95} options = {"quality": 95}
class BookXxLargeWebp(ImageSpec): class BookXxLargeWebp(ImageSpec):
"""Handles XxLarge size in Webp format"""
processors = [ResizeToFit(500, 500)] processors = [ResizeToFit(500, 500)]
format = "WEBP" format = "WEBP"
options = {"quality": 95} options = {"quality": 95}
class BookXxLargeJpg(ImageSpec): class BookXxLargeJpg(ImageSpec):
"""Handles XxLarge size in Jpeg format"""
processors = [ResizeToFit(500, 500)] processors = [ResizeToFit(500, 500)]
format = "JPEG" format = "JPEG"
options = {"quality": 95} options = {"quality": 95}

View file

@ -9,7 +9,12 @@ from imagekit.models import ImageSpecField
from bookwyrm import activitypub from bookwyrm import activitypub
from bookwyrm.preview_images import generate_edition_preview_image_task from bookwyrm.preview_images import generate_edition_preview_image_task
from bookwyrm.settings import DOMAIN, DEFAULT_LANGUAGE, ENABLE_PREVIEW_IMAGES, ENABLE_THUMBNAIL_GENERATION from bookwyrm.settings import (
DOMAIN,
DEFAULT_LANGUAGE,
ENABLE_PREVIEW_IMAGES,
ENABLE_THUMBNAIL_GENERATION,
)
from .activitypub_mixin import OrderedCollectionPageMixin, ObjectMixin from .activitypub_mixin import OrderedCollectionPageMixin, ObjectMixin
from .base_model import BookWyrmModel from .base_model import BookWyrmModel