def monkey_patch(enabled=True):
    """Monkey patching PIL.Image.open method

    Args:
        enabled (bool): If the monkey patch should be activated or deactivated.

    """

    if enabled:
        Image.open = imdirect_open
    else:
        Image.open = pil_open
Monkey patching PIL.Image.open method

    Args:
        enabled (bool): If the monkey patch should be activated or deactivated.