Skip to content

Resizing may result in degraded quality because gamma is not compensated #1604

@znerol

Description

@znerol

Citing from http://www.4p8.com/eric.brasseur/gamma.html

Technically speaking, the problem is that "the computations are performed as if the scale of brightnesses was linear while in fact it is a power scale." In mathematical terms: "a gamma of 1.0 is assumed while it is 2.2." Lots of filters, plug-ins and scripts make the same error.

Pillow seems to be affected by that problem too as the following test script demonstrates:

from PIL import Image
from cStringIO import StringIO
from urllib2 import urlopen

f = urlopen('http://www.4p8.com/eric.brasseur/gamma_dalai_lama_gray.jpg')
img = Image.open(StringIO(f.read()))
img.show()

newsize = tuple([i/2 for i in img.size])
imgscaled = img.resize(newsize, Image.ANTIALIAS)
imgscaled.show()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions