{"id":15423014,"url":"https://github.com/letmaik/rawpy","last_synced_at":"2026-05-07T09:01:17.879Z","repository":{"id":20483771,"uuid":"23761821","full_name":"letmaik/rawpy","owner":"letmaik","description":"📷 RAW image processing for Python, a wrapper for libraw","archived":false,"fork":false,"pushed_at":"2025-03-01T10:14:00.000Z","size":85249,"stargazers_count":667,"open_issues_count":20,"forks_count":73,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-04-03T14:45:21.670Z","etag":null,"topics":["camera-calibration","camera-image","image-optimization","image-processing","python"],"latest_commit_sha":null,"homepage":"https://pypi.python.org/pypi/rawpy","language":"Cython","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/letmaik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-09-07T14:32:12.000Z","updated_at":"2025-04-02T21:33:46.000Z","dependencies_parsed_at":"2023-02-19T03:00:18.409Z","dependency_job_id":"4241a298-d99d-4667-aaab-a292ca3fbb4f","html_url":"https://github.com/letmaik/rawpy","commit_stats":{"total_commits":367,"total_committers":14,"mean_commits":"26.214285714285715","dds":0.0953678474114441,"last_synced_commit":"d368d56f2eb9e7bd1f4c2f783bc4873d177e321b"},"previous_names":[],"tags_count":46,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letmaik%2Frawpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letmaik%2Frawpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letmaik%2Frawpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letmaik%2Frawpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/letmaik","download_url":"https://codeload.github.com/letmaik/rawpy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248313934,"owners_count":21082945,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["camera-calibration","camera-image","image-optimization","image-processing","python"],"created_at":"2024-10-01T17:40:09.591Z","updated_at":"2026-05-07T09:01:17.873Z","avatar_url":"https://github.com/letmaik.png","language":"Cython","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003ca href=\"https://en.wikipedia.org/wiki/Bayer_filter\"\u003e\u003cimg width=\"500\" src=\"https://raw.githubusercontent.com/letmaik/rawpy/main/logo/logo.png\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nrawpy is an easy-to-use Python wrapper for the [LibRaw library][libraw].\nIt also contains some extra functionality for finding and repairing hot/dead pixels.\n\n[API Documentation](https://letmaik.github.io/rawpy/api/)\n\n[Jupyter notebook tutorials](https://github.com/letmaik/rawpy-notebooks/blob/master/README.md)\n\n## Sample code\n\nLoad a RAW file and save the postprocessed image using default [parameters](https://letmaik.github.io/rawpy/api/rawpy.Params.html):\n\n```python\nimport rawpy\nimport imageio.v3 as iio\n\npath = 'image.nef'\nwith rawpy.imread(path) as raw:\n    rgb = raw.postprocess()\niio.imwrite('default.tiff', rgb)\n```\n\nSave as 16-bit linear image:\n\n```python\nwith rawpy.imread(path) as raw:\n    rgb = raw.postprocess(gamma=(1,1), no_auto_bright=True, output_bps=16)\niio.imwrite('linear.tiff', rgb)\n```\n\nExtract embedded thumbnail/preview image and save as JPEG:\n\n```python\nwith rawpy.imread(path) as raw:\n    # raises rawpy.LibRawNoThumbnailError if thumbnail missing\n    # raises rawpy.LibRawUnsupportedThumbnailError if unsupported format\n    thumb = raw.extract_thumb()\nif thumb.format == rawpy.ThumbFormat.JPEG:\n    # thumb.data is already in JPEG format, save as-is\n    with open('thumb.jpeg', 'wb') as f:\n        f.write(thumb.data)\nelif thumb.format == rawpy.ThumbFormat.BITMAP:\n    # thumb.data is an RGB numpy array, convert with imageio\n    iio.imwrite('thumb.jpeg', thumb.data)\n```\n\nFind bad pixels using multiple RAW files and repair them:\n\n```python\nimport rawpy.enhance\n\npaths = ['image1.nef', 'image2.nef', 'image3.nef']\nbad_pixels = rawpy.enhance.find_bad_pixels(paths)\n\nfor path in paths:\n    with rawpy.imread(path) as raw:\n        rawpy.enhance.repair_bad_pixels(raw, bad_pixels, method='median')\n        rgb = raw.postprocess()\n    iio.imwrite(path + '.tiff', rgb)\n```\n\n## Installation\n\nInstall rawpy by running:\n```sh\npip install rawpy\n```\n\n64-bit binary wheels are provided for Linux, macOS, and Windows.\n\n### Stable vs. pre-release\n\nAll stable rawpy releases are always built against a stable LibRaw library release.\nYou can output the LibRaw version with `print(rawpy.libraw_version)`.\n\nrawpy pre-releases have version numbers like `0.15.0a1` and are built against\na recent LibRaw snapshot. To install a pre-release, run:\n```sh\npip install --pre rawpy\n```\n\n### Optional features\n\nThe underlying [LibRaw library][libraw] supports several optional features.\nThe following table shows which PyPI binary wheels support which features.\n\n| Feature            | Windows | macOS | Linux |\n| ------------------ | ------- | ----- | ----- |\n| LCMS color engine  | yes     | yes   | yes   |\n| RedCine codec      | yes     | yes   | yes   |\n| DNG deflate codec  | yes     | yes   | yes   |\n| DNG lossy codec    | yes     | yes   | yes   |\n| Demosaic Pack GPL2 | no      | no    | no    |\n| Demosaic Pack GPL3 | no      | no    | no    |\n| OpenMP             | yes     | no    | yes   |\n\nTip: You can dynamically query supported features by inspecting the `rawpy.flags` dictionary.\n\nNote on GPL demosaic packs: The GPL2 and GPL3 demosaic packs are not included as rawpy is licensed\nunder the MIT license which is incompatible with GPL.\n\n### Installation from source on Linux/macOS\n\nFor macOS, LibRaw is built as part of the rawpy build (see external/).\nFor Linux, you need to install the LibRaw library on your system.\n\nOn Ubuntu, you can get (an outdated) version with:\n\n```sh\nsudo apt-get install libraw-dev\n```\n\nOr install the latest release version from the source repository:\n\n```sh\ngit clone https://github.com/LibRaw/LibRaw.git libraw\ngit clone https://github.com/LibRaw/LibRaw-cmake.git libraw-cmake\ncd libraw\ngit checkout 0.20.0\ncp -R ../libraw-cmake/* .\ncmake .\nsudo make install\n```\n    \nAfter that, install rawpy using:\n\n```sh\ngit clone https://github.com/letmaik/rawpy\ncd rawpy\npip install numpy cython\npip install .\n```\n    \nOn Linux, if you get the error \"ImportError: libraw.so: cannot open shared object file: No such file or directory\"\nwhen trying to use rawpy, then do the following:\n\n```sh\necho \"/usr/local/lib\" | sudo tee /etc/ld.so.conf.d/99local.conf\nsudo ldconfig\n```\n\nThe LibRaw library is installed in /usr/local/lib (if installed manually) and apparently this folder is not searched\nfor libraries by default in some Linux distributions.\n\n### Installation from source on Windows\n\nThese instructions are experimental and support is not provided for them.\nTypically, there should be no need to build manually since wheels are hosted on PyPI.\n\nYou need to have Visual Studio and Python installed to build rawpy.\n\nIn a PowerShell window:\n```sh\n$env:PYTHON_VERSION = '3.12'\n$env:PYTHON_ARCH = 'x86_64'\ngit clone https://github.com/letmaik/rawpy\ncd rawpy\ngit submodule update --init\n.github/scripts/build-windows.ps1\n```\n\n## FAQ\n\n### I'm getting deadlocks when using multiprocessing on Linux\n\nIf you're experiencing deadlocks when using rawpy with Python's `multiprocessing` module on Linux, this is caused by an interaction between OpenMP (which is enabled in the Linux wheels) and the default `fork` start method used by multiprocessing.\n\n**The Problem:**\nWhen a process using OpenMP is forked, OpenMP's internal thread pool state becomes inconsistent in the child process, which can cause deadlocks on subsequent calls to rawpy functions.\n\n**The Solution:**\nUse the `spawn` or `forkserver` start method instead of `fork`:\n\n```python\nimport multiprocessing as mp\nimport rawpy\n\ndef process_raw(filename):\n    with rawpy.imread(filename) as raw:\n        rgb = raw.postprocess()\n    return rgb\n\nif __name__ == '__main__':\n    # Set the start method to 'spawn' before creating any processes\n    mp.set_start_method('spawn')\n    \n    with mp.Pool(processes=4) as pool:\n        results = pool.map(process_raw, ['image1.nef', 'image2.nef'])\n```\n\n**Note:** The start method can only be set once per program, and must be called within an `if __name__ == '__main__':` guard. The `spawn` method creates a fresh Python interpreter process, avoiding the OpenMP thread state issue entirely.\n\nFor more information, see:\n- [Python multiprocessing documentation on start methods](https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods)\n- [OpenMP and fork() interaction issues](https://github.com/isl-org/Open3D/wiki/Deadlock-with-multiprocessing-(using-fork)-and-OpenMP)\n\n### I'm getting \"LibRawFileUnsupportedError: Unsupported file format or not RAW file\"\n\nThis error occurs when rawpy/LibRaw cannot recognize the file as a supported RAW image format. Common causes include:\n\n1. **The file is not actually a RAW file** - Make sure you're trying to open a RAW image file (e.g., .NEF, .CR2, .ARW, .DNG, etc.) and not a regular image format like JPEG or PNG.\n\n2. **The file is corrupted or incomplete** - If the file was not fully downloaded or is damaged, LibRaw cannot read it properly.\n\n3. **The file lacks proper headers** - Some proprietary or headerless RAW formats are not supported by LibRaw. RAW files need to contain proper metadata headers that identify the camera model, sensor configuration, and other essential information for LibRaw to decode them.\n\n4. **Unsupported camera or RAW format** - While LibRaw supports a [wide range of cameras](https://www.libraw.org/supported-cameras), some very new or obscure camera models may not be supported yet. Check the LibRaw website for the list of supported cameras.\n\n**What you can do:**\n- Verify the file is a genuine RAW file from a supported camera\n- Try opening the file with the camera manufacturer's software to confirm it's valid\n- Check if you're using the latest version of rawpy, as newer versions may support additional cameras\n- If you have a headerless or proprietary RAW format, you may need to convert it to a standard format like DNG using the camera manufacturer's tools first\n\n[libraw]: https://www.libraw.org\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fletmaik%2Frawpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fletmaik%2Frawpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fletmaik%2Frawpy/lists"}