I use the Python Image Library (PIL) to resize the image and create a thumbnail. Why is my code creating an image so crappy and substandard? Can someone tell me how to change the code so that it is the highest quality JPEG?
def create_thumbnail(buffer, width=100, height=100): im = Image.open(StringIO(buffer)) if im.mode not in ('L', 'RGB', 'RGBA'): im = im.convert('RGB') im.thumbnail((width, height), Image.ANTIALIAS) thumbnail_file = StringIO() im.save(thumbnail_file, 'JPEG') thumbnail_file.seek(0) return thumbnail_file
TIMEX source share