def _checkBitsPerPixel(value):
    """
    Raise a ValueError if the bitsPerPixel value isn't 4 or 8.
    """
    if value not in [4, 8]:
        raise ValueError(
            f'bitsPerPixel is only allowed to be 4 or 8, not {value}!')
