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

Commit

Permalink
PIL is kinda confusing
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Sinchok committed May 28, 2014
1 parent a2162f8 commit 215293c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions betty/cropper/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def new(request):
# Cache the icc_profile, in case we need to resize this on save.
icc_profile = img.info.get("icc_profile")
if img.format == "JPEG":
quantization = JpegImagePlugin.convert_dict_qtables(img.quantization)
quantization = img.quantization
sampling = JpegImagePlugin.get_sampling(img)

# If the image is a GIF, we need to do some special stuff
Expand Down Expand Up @@ -129,7 +129,7 @@ def new(request):
optimized_path,
icc_profile=icc_profile,
quality="keep",
qtables=quantization,
quantization=quantization,
subsampling=sampling)
else:
img.save(optimized_path, icc_profile=icc_profile)
Expand Down
4 changes: 2 additions & 2 deletions betty/cropper/management/commands/optimize_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def handle(self, *args, **options):
img = PILImage.open(image.source.path)
icc_profile = img.info.get("icc_profile")
if img.format == "JPEG":
qtables = JpegImagePlugin.convert_dict_qtables(img.quantization)
quantization = img.quantization
subsampling = JpegImagePlugin.get_sampling(img)

if img.size[0] > (settings.BETTY_MAX_WIDTH * 2):
Expand All @@ -32,7 +32,7 @@ def handle(self, *args, **options):
img.save(
optimized_path,
icc_profile=icc_profile,
qtables=qtables,
quantization=quantization,
subsampling=subsampling)
else:
img.save(optimized_path, icc_profile=icc_profile)
Expand Down
2 changes: 1 addition & 1 deletion betty/cropper/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def search_image_quality(image_id):
search_im.save(
original_path,
"JPEG",
qtables=JpegImagePlugin.convert_dict_qtables(im.quantization),
quantization=im.quantization,
subsampling=JpegImagePlugin.get_sampling(im),
icc_profile=icc_profile)
optimized_path = tempfile.mkstemp()[1]
Expand Down

0 comments on commit 215293c

Please sign in to comment.