Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

Commit

Permalink
Upgrading Pillow
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Sinchok committed Sep 14, 2014
1 parent 273356b commit ddc78f8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
16 changes: 1 addition & 15 deletions betty/cropper/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,14 @@ def optimize_image(image):
height = settings.BETTY_MAX_WIDTH * float(im.size[1]) / float(im.size[0])
im = im.resize((settings.BETTY_MAX_WIDTH, int(round(height))), PILImage.ANTIALIAS)

"""OK, so this suuuuuucks. When we convert or resize an Image, it
is no longer a JPEG. So, in order to reset the quanitzation, etc,
we need to save this to a file and then re-read it from the
filesystem. Silly, I know. Once my pull request is approved, this
can be removed, and we can just pass the qtables into the save method.
PR is here: https://github.com/python-imaging/Pillow/pull/677
"""
temp = tempfile.NamedTemporaryFile()
im.save(temp, format="JPEG")
temp.seek(0)
im = PILImage.open(temp)

im.quantization = quantization

image.optimized.name = optimized_upload_to(image, filename)
if format == "JPEG" and im.mode == "RGB":
# For JPEG files, we need to make sure that we keep the quantization profile
try:
im.save(
image.optimized.name,
icc_profile=icc_profile,
quality="keep",
qtables=quantization,
subsampling=subsampling,
format="JPEG")
except (TypeError, ValueError) as e:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Django>=1.5
logan==0.5.9.1
slimit==0.8.1
Pillow==2.4.0
Pillow==2.5.3
South==0.8.4
jsonfield==0.9.20
six==1.6.1
Expand Down

0 comments on commit ddc78f8

Please sign in to comment.