Skip to content

Instantly share code, notes, and snippets.

Stephen Arthur thebostik

Block or report user

Report or block thebostik

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
thebostik /
Created May 30, 2017
Photo Upload Starting Point
# do a typical thumbnail, preserving aspect ratio
new_photo = photo.copy()
(width, height),
thumbfile = cStringIO.StringIO()
save_args = {'format': format}
if format == 'JPEG':
save_args['quality'] = 85
thebostik / Dockerfile
Created May 30, 2017
Mozjpeg + Pillow Dockerfile
View Dockerfile
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 \
thebostik /
Created May 30, 2017
Python Dynamic Image Quality Example
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
You can’t perform that action at this time.