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
# do a typical thumbnail, preserving aspect ratio | |
new_photo = photo.copy() | |
new_photo.thumbnail( | |
(width, height), | |
resample=PIL.Image.ANTIALIAS, | |
) | |
thumbfile = cStringIO.StringIO() | |
save_args = {'format': format} | |
if format == 'JPEG': | |
save_args['quality'] = 85 |
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
FROM ubuntu:xenial | |
RUN apt-get update \ | |
&& DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends install \ | |
# build tools | |
nasm \ | |
build-essential \ | |
autoconf \ | |
automake \ | |
libtool \ |
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
import cStringIO | |
import PIL.Image | |
from ssim import compute_ssim | |
def get_ssim_at_quality(photo, quality): | |
"""Return the ssim for this JPEG image saved at the specified quality""" | |
ssim_photo = cStringIO.StringIO() | |
# optimize is omitted here as it doesn't affect | |
# quality but requires additional memory and cpu |