The interesting trick about sepia images is that they are just gray-scale pictures with a different color palette. In this case the sepia color I’m using is #FFF0C0.
Doing this on PIL is quite straight forward (from effbot’s blog):
# You have your PIL Image instance on a 'im' variable # Convert it to grayscale im = im.convert('L') # L mode means gray-scale # Set the sepia palette im.putpalette(linear_ramp) # will explain this later # Make RGB again im = im.convert('RGB')
And there you have it. Now the
linear_ramp variable. It is actually a map of 256 blocks indicating what color to use for each of the possible gray-scale values (white to black). You can see the original blog post on how to build the
If you just want to turn your images to gray-scale instead of sepia, set sorl-sepia
SORL_DEFAULT_SEPIA_TONE setting to (0, 0, 0).