{"id":15671538,"url":"https://github.com/winstxnhdw/pixwin","last_synced_at":"2025-05-06T20:27:01.418Z","repository":{"id":63665255,"uuid":"563609483","full_name":"winstxnhdw/PixWin","owner":"winstxnhdw","description":"A fast Python API for retrieving RGB values of a pixel on Windows using C extensions and ctypes.","archived":false,"fork":false,"pushed_at":"2025-05-02T10:56:28.000Z","size":240,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-02T11:47:51.817Z","etag":null,"topics":["ctypes","getpixel","pyscreeze","python-c-extension","win32-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/winstxnhdw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2022-11-09T00:52:08.000Z","updated_at":"2025-05-02T10:56:26.000Z","dependencies_parsed_at":"2024-03-03T01:38:34.634Z","dependency_job_id":"3500d5c9-8ce5-4993-b78f-609e78cb365d","html_url":"https://github.com/winstxnhdw/PixWin","commit_stats":{"total_commits":84,"total_committers":4,"mean_commits":21.0,"dds":0.5357142857142857,"last_synced_commit":"369297286045fc4b96b2fc8927aa1d20c6f22e25"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winstxnhdw%2FPixWin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winstxnhdw%2FPixWin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winstxnhdw%2FPixWin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winstxnhdw%2FPixWin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/winstxnhdw","download_url":"https://codeload.github.com/winstxnhdw/PixWin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252763350,"owners_count":21800468,"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":["ctypes","getpixel","pyscreeze","python-c-extension","win32-api"],"created_at":"2024-10-03T15:03:19.127Z","updated_at":"2025-05-06T20:27:01.398Z","avatar_url":"https://github.com/winstxnhdw.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# PixWin\n\n[![python](https://img.shields.io/badge/python-3.8%20|%203.9%20|%203.10%20|%203.11%20|%203.12-blue)](https://www.python.org/)\n[![linting: pylint](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/PyCQA/pylint)\n[![main.yml](https://github.com/winstxnhdw/PixWin/actions/workflows/main.yml/badge.svg)](https://github.com/winstxnhdw/PixWin/actions/workflows/main.yml)\n[![formatter.yml](https://github.com/winstxnhdw/PixWin/actions/workflows/formatter.yml/badge.svg)](https://github.com/winstxnhdw/PixWin/actions/workflows/formatter.yml)\n[![dependabot.yml](https://github.com/winstxnhdw/PixWin/actions/workflows/dependabot.yml/badge.svg)](https://github.com/winstxnhdw/PixWin/actions/workflows/dependabot.yml)\n\n`PixWin` is a fast Python API for retrieving RGB values of a pixel on Windows. It uses Python C extensions and ctypes to access [GetPixel()](https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getpixel) within the Win32 API.\n\n## Installation\n\n```bash\npip install git+https://github.com/winstxnhdw/PixWin\n```\n\n## Usage\n\n```python\nfrom pixwin import PixWin\n\n\ndef loop(pixwin: PixWin):\n\n    while True:\n        print(pixwin.get_pixel(420, 69))        # e.g. (42, 21, 13)\n        print(pixwin.get_red_value(420, 69))    # e.g. 42\n        print(pixwin.get_blue_value(420, 69))   # e.g. 21\n        print(pixwin.get_green_value(420, 69))  # e.g. 13\n\n\ndef main():\n\n    with PixWin() as pixwin:\n        try:\n            loop(pixwin)\n\n        except KeyboardInterrupt:\n            print('Manual exit detected.')\n\n\nif __name__ == '__main__':\n    main()\n```\n\n## Benchmarks\n\nSimilar to PixWin, [PyScreeze](https://github.com/asweigart/pyscreeze) retrieves pixel values via the Win32 API. PixWin is ~15000x faster than [PyScreeze](https://github.com/asweigart/pyscreeze).\n\n### Single-pixel retrieval\n\n\u003cdetails\u003e\n\n\u003csummary\u003ePixWin\u003c/summary\u003e\n\n```python\nfrom cProfile import run\nfrom pixwin import PixWin\n\n\nwith PixWin() as pixwin:\n    def get_pixel():\n        \"\"\"\n        Summary\n        -------\n        retrieve a single pixel value\n        \"\"\"\n        pixwin.get_pixel(0, 0)\n\n\nif __name__ == '__main__':\n    run('get_pixel()')\n```\n\n\u003c/details\u003e\n\n```txt\n6 function calls in 0.000 seconds\n\nncalls  tottime  percall  cumtime  percall filename:lineno(function)\n    1    0.000    0.000    0.000    0.000 \u003cstring\u003e:1(\u003cmodule\u003e)\n    1    0.000    0.000    0.000    0.000 __init__.py:33(get_pixel)\n    1    0.000    0.000    0.000    0.000 test.py:5(pixwin)\n    1    0.000    0.000    0.000    0.000 {built-in method builtins.exec}\n    1    0.000    0.000    0.000    0.000 {built-in method pixwin.get_pixel.get_rgb}\n    1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}\n```\n\n\u003cdetails\u003e\n\n\u003csummary\u003e\u003ca href=\"https://github.com/asweigart/pyscreeze\"\u003easweigart/pyscreeze\u003c/a\u003e\u003c/summary\u003e\n\n```python\nfrom cProfile import run\nfrom pyscreeze import pixel\n\n\ndef pyscreeze():\n    \"\"\"\n    Summary\n    -------\n    retrieve a single pixel value\n    \"\"\"\n    pixel(0, 0)\n\n\nif __name__ == '__main__':\n    run('pyscreeze()')\n```\n\n\u003c/details\u003e\n\n```txt\n41 function calls in 0.007 seconds\n\nncalls  tottime  percall  cumtime  percall filename:lineno(function)\n    1    0.000    0.000    0.007    0.007 \u003cstring\u003e:1(\u003cmodule\u003e)\n    2    0.000    0.000    0.000    0.000 __init__.py:110(__win32_openDC)\n    1    0.000    0.000    0.000    0.000 __init__.py:340(__init__)\n    1    0.000    0.000    0.000    0.000 __init__.py:368(_FuncPtr)\n    3    0.000    0.000    0.000    0.000 __init__.py:391(__getitem__)\n    1    0.000    0.000    0.000    0.000 __init__.py:441(__getattr__)\n    1    0.007    0.007    0.007    0.007 __init__.py:601(pixel)\n    4    0.000    0.000    0.000    0.000 __init__.py:613(\u003cgenexpr\u003e)\n    1    0.000    0.000    0.000    0.000 contextlib.py:102(__init__)\n    1    0.000    0.000    0.000    0.000 contextlib.py:130(__enter__)\n    1    0.000    0.000    0.000    0.000 contextlib.py:139(__exit__)\n    1    0.000    0.000    0.000    0.000 contextlib.py:279(helper)\n    1    0.000    0.000    0.007    0.007 test.py:12(pyscreeze)\n    1    0.000    0.000    0.000    0.000 {built-in method _ctypes.LoadLibrary}\n    1    0.000    0.000    0.000    0.000 {built-in method builtins.__build_class__}\n    1    0.000    0.000    0.007    0.007 {built-in method builtins.exec}\n    1    0.000    0.000    0.000    0.000 {built-in method builtins.getattr}\n    3    0.000    0.000    0.000    0.000 {built-in method builtins.isinstance}\n    2    0.000    0.000    0.000    0.000 {built-in method builtins.next}\n    4    0.000    0.000    0.000    0.000 {built-in method builtins.setattr}\n    1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}\n    1    0.000    0.000    0.000    0.000 {method 'format' of 'str' objects}\n    4    0.000    0.000    0.000    0.000 {method 'startswith' of 'str' objects}\n```\n\n### Multi-pixel retrieval\n\n\u003cdetails\u003e\n\n\u003csummary\u003ePixWin\u003c/summary\u003e\n\n```python\nimport cProfile as profile\nfrom pixwin import PixWin\n\n\nwith PixWin() as pixwin:\n    def get_pixel():\n        \"\"\"\n        Summary\n        -------\n        retrieve multiple pixel values\n        \"\"\"\n        [pixwin.get_pixel(0, 0) for _ in range(10000)]\n\n\nif __name__ == '__main__':\n    profile.run('get_pixel()')\n```\n\n\u003c/details\u003e\n\n```txt\n20004 function calls in 0.006 seconds\n\nncalls  tottime  percall  cumtime  percall filename:lineno(function)\n    1    0.000    0.000    0.006    0.006 \u003cstring\u003e:1(\u003cmodule\u003e)\n10000    0.002    0.000    0.004    0.000 __init__.py:33(get_pixel)\n    1    0.000    0.000    0.006    0.006 test.py:5(pixwin)\n    1    0.002    0.002    0.006    0.006 test.py:6(\u003clistcomp\u003e)\n    1    0.000    0.000    0.006    0.006 {built-in method builtins.exec}\n10000    0.003    0.000    0.003    0.000 {built-in method pixwin.get_pixel.get_rgb}\n    1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}\n```\n\n\u003cdetails\u003e\n\n\u003csummary\u003e\u003ca href=\"https://github.com/asweigart/pyscreeze\"\u003easweigart/pyscreeze\u003c/a\u003e\u003c/summary\u003e\n\n```python\nfrom cProfile import run\nfrom pyscreeze import pixel\n\n\ndef pyscreeze():\n    \"\"\"\n    Summary\n    -------\n    retrieve multiple pixel values\n    \"\"\"\n    [pixel(0, 0) for _ in range(10000)]\n\n\nif __name__ == '__main__':\n    run('pyscreeze()')\n```\n\n\u003c/details\u003e\n\n```txt\n150027 function calls in 89.460 seconds\n\nncalls  tottime  percall  cumtime  percall filename:lineno(function)\n    1    0.000    0.000   89.460   89.460 \u003cstring\u003e:1(\u003cmodule\u003e)\n20000    0.310    0.000    0.310    0.000 __init__.py:110(__win32_openDC)\n    1    0.000    0.000    0.000    0.000 __init__.py:340(__init__)\n    1    0.000    0.000    0.000    0.000 __init__.py:368(_FuncPtr)\n    3    0.000    0.000    0.000    0.000 __init__.py:384(__getattr__)\n    3    0.000    0.000    0.000    0.000 __init__.py:391(__getitem__)\n    1    0.000    0.000    0.000    0.000 __init__.py:441(__getattr__)\n10000   88.936    0.009   89.440    0.009 __init__.py:601(pixel)\n40000    0.044    0.000    0.044    0.000 __init__.py:613(\u003cgenexpr\u003e)\n10000    0.029    0.000    0.035    0.000 contextlib.py:102(__init__)\n10000    0.010    0.000    0.123    0.000 contextlib.py:130(__enter__)\n10000    0.029    0.000    0.241    0.000 contextlib.py:139(__exit__)\n10000    0.014    0.000    0.049    0.000 contextlib.py:279(helper)\n    1    0.000    0.000   89.460   89.460 test.py:5(pyscreeze)\n    1    0.019    0.019   89.460   89.460 test.py:7(\u003clistcomp\u003e)\n    1    0.000    0.000    0.000    0.000 {built-in method _ctypes.LoadLibrary}\n    1    0.000    0.000    0.000    0.000 {built-in method builtins.__build_class__}\n    1    0.000    0.000   89.460   89.460 {built-in method builtins.exec}\n10000    0.006    0.000    0.006    0.000 {built-in method builtins.getattr}\n    3    0.000    0.000    0.000    0.000 {built-in method builtins.isinstance}\n20000    0.015    0.000    0.325    0.000 {built-in method builtins.next}\n    4    0.000    0.000    0.000    0.000 {built-in method builtins.setattr}\n    1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}\n10000    0.048    0.000    0.048    0.000 {method 'format' of 'str' objects}\n    4    0.000    0.000    0.000    0.000 {method 'startswith' of 'str' objects}\n```\n\n## Development\n\nYou can build locally by running the following.\n\n```bash\npoetry build\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwinstxnhdw%2Fpixwin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwinstxnhdw%2Fpixwin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwinstxnhdw%2Fpixwin/lists"}