summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2016-03-21 09:09:49 -0400
committerluxagraf <sng@luxagraf.net>2016-03-21 09:09:49 -0400
commitf2ebf135bbf0104d655160011571927ae459f728 (patch)
tree68473492bd6e38d3c698926b15ee419a7034f768
parent96d80eaf238045faba45cd4b64a8d93d19a98a69 (diff)
tweaked image size and quality settings
-rw-r--r--app/photos/models.py2
-rw-r--r--app/photos/utils.py2
2 files changed, 3 insertions, 1 deletions
diff --git a/app/photos/models.py b/app/photos/models.py
index 46c659e..048dd65 100644
--- a/app/photos/models.py
+++ b/app/photos/models.py
@@ -125,7 +125,7 @@ def update_photo_sizes(sender, instance, **kwargs):
print("hellow world")
base_path = "%s/%s/" % (settings.IMAGES_ROOT, instance.pub_date.strftime("%Y"))
img = Image.open(instance.image.path)
- resize_image(img, 160, None, 65, base_path, "%s_tn.%s" % (instance.get_image_name(), instance.get_image_ext()))
+ resize_image(img, 160, None, 78, base_path, "%s_tn.%s" % (instance.get_image_name(), instance.get_image_ext()))
for size in instance.sizes.all():
print(size.width)
resize_image(img, size.width, None, size.quality, base_path, "%s_%s.%s" % (instance.get_image_name(), size.width, instance.get_image_ext()))
diff --git a/app/photos/utils.py b/app/photos/utils.py
index e880277..28047d4 100644
--- a/app/photos/utils.py
+++ b/app/photos/utils.py
@@ -1,5 +1,6 @@
import os
import subprocess
+from PIL import ImageFile
# pip install python-resize-image
from resizeimage import resizeimage
@@ -15,5 +16,6 @@ def resize_image(img, width=None, height=None, quality=72, base_path="", filenam
if not os.path.isdir(base_path):
os.makedirs(base_path)
path = "%s%s" % (base_path, filename)
+ ImageFile.MAXBLOCK = img.size[0] * img.size[1] * 4
newimg.save(path, newimg.format, quality=quality)
subprocess.call(["jpegoptim", "%s" % path])