diff --git a/avatar/conf.py b/avatar/conf.py index 2af38ab..bb25c4f 100644 --- a/avatar/conf.py +++ b/avatar/conf.py @@ -15,7 +15,7 @@ class AvatarConf(AppConf): DEFAULT_URL = "avatar/img/default.jpg" MAX_AVATARS_PER_USER = 42 MAX_SIZE = 1024 * 1024 - THUMB_FORMAT = "JPEG" + THUMB_FORMAT = "PNG" THUMB_QUALITY = 85 HASH_FILENAMES = False HASH_USERDIRNAMES = False diff --git a/docs/index.txt b/docs/index.txt index d6128ce..e36b250 100644 --- a/docs/index.txt +++ b/docs/index.txt @@ -205,14 +205,22 @@ appear on the site. Listed below are those settings: .. py:data:: AVATAR_RESIZE_METHOD The method to use when resizing images, based on the options available in - PIL. Defaults to ``Image.ANTIALIAS``. + Pillow. Defaults to ``Image.ANTIALIAS``. .. py:data:: AVATAR_STORAGE_DIR The directory under ``MEDIA_ROOT`` to store the images. If using a non-filesystem storage device, this will simply be appended to the beginning of the file name. Defaults to ``avatars``. - PIL. Defaults to ``Image.ANTIALIAS``. + Pillow. Defaults to ``Image.ANTIALIAS``. + +.. py:data:: AVATAR_THUMB_FORMAT + The file format of thumbnails, based on the options available in + Pillow. Defaults to `PNG`. + +.. py:data:: AVATAR_THUMB_QUALITY + The quality of thumbnails, between 0 (worst) to 95 (best) or the string + "keep" (only JPEG) as provided by Pillow. Defaults to `85`. .. py:data:: AVATAR_CLEANUP_DELETED diff --git a/setup.py b/setup.py index b58b54e..3c03009 100644 --- a/setup.py +++ b/setup.py @@ -58,8 +58,8 @@ setup( ], }, install_requires=[ - "Pillow>=2.0", - "django-appconf>=0.6", + "Pillow>=9.2.0", + "django-appconf>=1.0.5", ], zip_safe=False, ) diff --git a/tests/settings.py b/tests/settings.py index 7dc5607..458c42d 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -38,6 +38,7 @@ TEMPLATES = [ "context_processors": [ "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", + "django.template.context_processors.request", ] }, } diff --git a/tests/tests.py b/tests/tests.py index 6763a5f..c1ca0ca 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -217,7 +217,6 @@ class AvatarTests(TestCase): self.assertNotEqual(response.context["upload_avatar_form"].errors, {}) self.assertEqual(count_before, count_after) - @override_settings(AVATAR_THUMB_FORMAT="png") def test_automatic_thumbnail_creation_RGBA(self): upload_helper(self, "django.png") avatar = get_primary_avatar(self.user) @@ -228,6 +227,7 @@ class AvatarTests(TestCase): ) self.assertEqual(image.mode, "RGBA") + @override_settings(AVATAR_THUMB_FORMAT="JPEG") def test_automatic_thumbnail_creation_CMYK(self): upload_helper(self, "django_pony_cmyk.jpg") avatar = get_primary_avatar(self.user)