Download: latest (1.8.0)

pymagery — python imagery


1.5.0 documentation / lightness plugin

The lightness plugin adjusts the lightness (according to HSL) by a specified additive or multiplicative value. HSL has lightness on [0,1] but for the purposes of this plugin it is scaled to [0,100].

The plugin prototype is:

def lightness(width, add=None, mult=None)

One of the parameters should be supplied. The @add parameter should be a value on [-100,100]. The @mult parameter should be a value on [0, infinity).

If 100 were added then the image will be made completely white. If -100 were added (or 0.0 were multiplied) then the image will be made completely black. If 0 were added (or 1.0 were multiplied) then the image will be unchanged.

Additive Result Image
-100
-75
-50
-25
0
25
50
75
100

The code to generate the above images could be:

from pymagery import image i = image('ISU_mute_swans.ppm') i.COPY().LIGHTNESS(add=-100).save('ISU_mute_swans-lightness--100.ppm') i.COPY().LIGHTNESS(add=-75).save('ISU_mute_swans-lightness--75.ppm') i.COPY().LIGHTNESS(add=-50).save('ISU_mute_swans-lightness--50.ppm') i.COPY().LIGHTNESS(add=-25).save('ISU_mute_swans-lightness--25.ppm') i.COPY().LIGHTNESS(add=0).save('ISU_mute_swans-lightness-0.ppm') i.COPY().LIGHTNESS(add=25).save('ISU_mute_swans-lightness-25.ppm') i.COPY().LIGHTNESS(add=50).save('ISU_mute_swans-lightness-50.ppm') i.COPY().LIGHTNESS(add=75).save('ISU_mute_swans-lightness-75.ppm') i.COPY().LIGHTNESS(add=100).save('ISU_mute_swans-lightness-100.ppm')

Change Log