{"id":6849,"library":"rawpy","title":"rawpy","description":"rawpy is an easy-to-use Python wrapper for the LibRaw library, providing comprehensive RAW image processing capabilities. It also includes functionality for finding and repairing hot/dead pixels. The library is actively maintained with regular updates, often driven by new LibRaw releases and Python version support. The current version is 0.26.1.","status":"active","version":"0.26.1","language":"en","source_language":"en","source_url":"https://github.com/letmaik/rawpy","tags":["image processing","RAW","photography","libraw","computer vision"],"install":[{"cmd":"pip install rawpy","lang":"bash","label":"Install stable version"},{"cmd":"pip install --pre rawpy","lang":"bash","label":"Install pre-release version"}],"dependencies":[{"reason":"Core dependency for array operations and image data representation.","package":"numpy"},{"reason":"Commonly used for saving processed images, as shown in quickstart examples.","package":"imageio","optional":true}],"imports":[{"symbol":"rawpy","correct":"import rawpy"},{"note":"For advanced features like bad pixel detection and repair.","symbol":"rawpy.enhance","correct":"import rawpy.enhance"}],"quickstart":{"code":"import rawpy\nimport imageio.v3 as iio\nimport os\n\n# Create a dummy RAW file for demonstration (replace with your .CR2, .NEF, etc.)\n# In a real scenario, you would have an actual RAW image file.\ndummy_raw_content = b'\\x00' * 1024 # Not a real RAW, but allows the code to run without file not found\ndummy_raw_filename = 'dummy.nef'\nwith open(dummy_raw_filename, 'wb') as f:\n    f.write(dummy_raw_content)\n\npath = dummy_raw_filename\n\ntry:\n    # Load a RAW file using the context manager for resource safety\n    with rawpy.imread(path) as raw:\n        # Postprocess the RAW image to an RGB NumPy array\n        # Uses default parameters for demosaicing, white balance, etc.\n        rgb = raw.postprocess()\n\n        # Save the postprocessed image using imageio (requires 'imageio' installed)\n        output_filename = 'default.tiff'\n        iio.imwrite(output_filename, rgb)\n        print(f\"Image saved to {output_filename}\")\n\n        # Example: Save as 16-bit linear image\n        rgb_16bit = raw.postprocess(gamma=(1,1), no_auto_bright=True, output_bps=16)\n        output_filename_16bit = 'linear.tiff'\n        iio.imwrite(output_filename_16bit, rgb_16bit)\n        print(f\"16-bit linear image saved to {output_filename_16bit}\")\n\nexcept rawpy.LibRawFileUnsupportedError:\n    print(f\"Error: '{path}' is not a supported RAW file format, or it's corrupted/incomplete.\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\nfinally:\n    # Clean up dummy file\n    if os.path.exists(dummy_raw_filename):\n        os.remove(dummy_raw_filename)\n","lang":"python","description":"This quickstart demonstrates how to load a RAW image, postprocess it using default settings, and save the resulting RGB image as a TIFF file. It also shows an example of saving a 16-bit linear image. It uses `imageio` for saving the output, which needs to be installed separately. The code includes basic error handling for unsupported RAW files and uses a dummy file for execution without requiring an actual RAW image upfront."},"warnings":[{"fix":"Use rawpy v0.25.x or earlier on macOS Intel, or migrate to a different architecture (e.g., Apple Silicon) or operating system.","message":"macOS Intel support was removed in v0.26.0. Users on macOS with Intel CPUs will not be able to install or use rawpy versions 0.26.0 and later.","severity":"breaking","affected_versions":">=0.26.0"},{"fix":"Implement explicit try-except blocks (e.g., for `rawpy.LibRawError` or `rawpy.LibRawFileUnsupportedError`) around file opening and processing to handle corrupted or unsupported RAW files gracefully.","message":"As of v0.23.0, rawpy will now raise an error for corrupt or malformed RAW files instead of silently returning garbage data. This improves robustness but may require updating existing code that implicitly handled such cases.","severity":"breaking","affected_versions":">=0.23.0"},{"fix":"Upgrade to Python 3.9 or newer.","message":"Python 3.8 support was dropped in v0.22.0. Users on Python 3.8 must upgrade their Python version to continue using recent rawpy releases.","severity":"breaking","affected_versions":">=0.22.0"},{"fix":"Upgrade numpy to a compatible version (e.g., `pip install --upgrade numpy`). Check rawpy's documentation for specific minimum numpy versions for your Python version.","message":"Numpy 2.x support was added in v0.22.0, but older numpy versions are no longer supported. Ensure your numpy installation is compatible with rawpy.","severity":"breaking","affected_versions":">=0.22.0"},{"fix":"Install `libraw-dev` (or equivalent) via your system's package manager (e.g., `sudo apt-get install libraw-dev` on Ubuntu) or compile `LibRaw` from source before installing `rawpy`.","message":"On Linux, `rawpy` requires the `LibRaw` library to be installed system-wide. Binary wheels for `rawpy` do not bundle `LibRaw` on Linux. Installation instructions for `LibRaw` vary by distribution.","severity":"gotcha","affected_versions":"All versions on Linux"},{"fix":"Verify the input file is a genuine, uncorrupted RAW image from a supported camera model. Use a `try-except` block to catch `rawpy.LibRawFileUnsupportedError` and handle unsupported files gracefully.","message":"Attempting to open a non-RAW file, a corrupted file, or a RAW file with an unsupported format/camera model will raise a `rawpy.LibRawFileUnsupportedError`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Change the multiprocessing start method to 'spawn' or 'forkserver' (e.g., `multiprocessing.set_start_method('spawn')`) before creating any `multiprocessing.Process` objects or pools.","message":"When using Python's `multiprocessing` module on Linux, deadlocks can occur due to an interaction between OpenMP (used in rawpy's Linux wheels) and the default `fork` start method.","severity":"gotcha","affected_versions":"All versions on Linux"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}