Created
January 21, 2010 22:28
-
-
Save pagenoare/283263 to your computer and use it in GitHub Desktop.
better image quality in thumbs.py (django) -> http://djangothumbnails.com/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- thumbs.py 2009-06-08 20:11:41.000000000 +0200 | |
+++ thumbs2.py 2010-01-23 14:48:25.000000000 +0100 | |
@@ -5,7 +5,7 @@ | |
""" | |
from django.db.models import ImageField | |
from django.db.models.fields.files import ImageFieldFile | |
-from PIL import Image | |
+from PIL import Image, ImageFilter | |
from django.core.files.base import ContentFile | |
import cStringIO | |
@@ -52,12 +52,13 @@ | |
image2 = image | |
image2.thumbnail(thumb_size, Image.ANTIALIAS) | |
+ image2.filter(ImageFilter.SMOOTH_MORE) | |
io = cStringIO.StringIO() | |
# PNG and GIF are the same, JPG is JPEG | |
if format.upper()=='JPG': | |
format = 'JPEG' | |
- image2.save(io, format) | |
+ image2.save(io, format, quality=95) | |
return ContentFile(io.getvalue()) | |
class ImageWithThumbsFieldFile(ImageFieldFile): | |
@@ -160,4 +161,4 @@ | |
self.width_field=width_field | |
self.height_field=height_field | |
self.sizes = sizes | |
- super(ImageField, self).__init__(**kwargs) | |
\ Brak znaku nowej linii na końcu pliku | |
+ super(ImageField, self).__init__(**kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment