Skip to content
This repository has been archived by the owner on Oct 4, 2020. It is now read-only.

Commit

Permalink
Move "constants" into immutable named tuples
Browse files Browse the repository at this point in the history
  • Loading branch information
SamWhited committed May 24, 2015
1 parent 3d31abf commit 6f1ef2c
Showing 1 changed file with 30 additions and 50 deletions.
80 changes: 30 additions & 50 deletions rawkit/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,36 @@

import ctypes

CLIP = 0
"""
Clip all highlights to white (default).
from collections import namedtuple

:dcraw: ``-H 0``
"""
IGNORE = 1
highlight_modes = namedtuple(
'HighlightMode', ['clip', 'ignore', 'blend', 'reconstruct']
)(0, 1, 2, 5)
"""
Leave highlights unclipped.
Constants for setting the highlight mode.
:dcraw: ``-H 1``
- ``clip`` --- Clip all highlights to white (default).
- ``ignore`` --- Leave highlights unclipped.
- ``blend`` --- Blend clipped and unclipped highlights.
- ``reconstruct`` --- A good average value for reconstruction of clipped
highlights which compromises between favoring whites and favoring colors.
"""
BLEND = 2
"""
Blend clipped and unclipped highlights.

:dcraw: ``-H 2``
"""
RECONSTRUCT = 5
colorspaces = namedtuple(
'ColorSpaces', ['raw', 'sRGB', 'adobe_rgb', 'wide_gammut_rgb',
'kodak_prophoto_rgb', 'xyz']
)(0, 1, 2, 3, 4, 5)
"""
A good average value for reconstruction of clipped highlights which
compromises between favoring whites and favoring colors.
:dcraw: ``-H 5``
Constants for setting the colorspace.
- ``raw_color`` --- Raw colorspace (unique to each camera)
- ``srgb`` --- sRGB D65 (default colorspace)
- ``adobe_rgb`` --- Adobe RGB (1998) D65
- ``wide_gammut_rgb`` --- Wide Gamut RGB D65
- ``kodak_prophoto_rgb`` --- Kodak ProPhoto RGB D65
- ``xyz`` --- XYZ colorspace
"""

raw_color = 0
"""Raw colorspace (unique to each camera)"""
srgb = 1
"""sRGB D65 (default colorspace)"""
adobe_rgb = 2
"""Adobe RGB (1998) D65"""
wide_gammut_rgb = 3
"""Wide Gamut RGB D65"""
kodak_prophoto_rgb = 4
"""Kodak ProPhoto RGB D65"""
xyz = 5
"""XYZ colorspace"""


class WhiteBalance(object):

Expand Down Expand Up @@ -110,18 +101,11 @@ def __init__(self):
@property
def colorspace(self):
"""
Sets the colorspace used for the output image. The following constants
may be used:
- :class:`rawkit.options.raw_color`
- :class:`rawkit.options.srgb`
- :class:`rawkit.options.adobe_rgb`
- :class:`rawkit.options.wide_gammut_rgb`
- :class:`rawkit.options.kodak_prophoto_rgb`
- :class:`rawkit.options.xyz`
Sets the colorspace used for the output image. Supported colorspaces
are defined as constants in :class:`rawkit.options.colorspaces`.
:type: :class:`int`
:default: :class:`rawkit.options.srgb`
:default: :class:`rawkit.options.colorspaces.srgb`
:dcraw: ``-o``
:libraw: :class:`rawkit.libraw.libraw_output_params_t.output_color`
"""
Expand All @@ -134,28 +118,24 @@ def colorspace(self, value):
@property
def highlight_mode(self):
"""
The mode for dealing with highlights in the image. Some constants hvae
been defined to make setting the highlight mode easier:
- :class:`rawkit.options.CLIP`
- :class:`rawkit.options.IGNORE`
- :class:`rawkit.options.BLEND`
- :class:`rawkit.options.RECONSTRUCT`
The mode for dealing with highlights in the image. Some constants have
been defined in :class:`rawkit.options.highlight_modes` to make things
easier, or you can set an integer directly.
Integers that are greater than or equal to 3 will attempt to
reconstruct highlights. Lower numbers favor whites, and higher colors
favor colors. :class:`rawkit.options.RECONSTRUCT` (5) is a good
compromise.
:type: :class:`int`
:default: :class:`rawkit.options.CLIP`
:default: :class:`rawkit.options.highlight_modes.clip`
:dcraw: ``-H``
:libraw: :class:`rawkit.libraw.libraw_output_params_t.highlight`
"""
if self._highlight_mode is not None:
return self._highlight_mode
else:
return CLIP
return highlight_modes.clip

@highlight_mode.setter
def highlight_mode(self, value):
Expand Down

0 comments on commit 6f1ef2c

Please sign in to comment.