{"id":25431930,"url":"https://github.com/jacklinquan/microbmp","last_synced_at":"2025-06-13T15:40:49.556Z","repository":{"id":45199672,"uuid":"261960780","full_name":"jacklinquan/microbmp","owner":"jacklinquan","description":"A small Python module for BMP image processing.","archived":false,"fork":false,"pushed_at":"2022-01-01T05:22:31.000Z","size":16,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-15T21:43:27.404Z","etag":null,"topics":["bmp","image","micropython","python"],"latest_commit_sha":null,"homepage":"","language":"Python","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/jacklinquan.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}},"created_at":"2020-05-07T05:47:45.000Z","updated_at":"2024-09-14T06:33:02.000Z","dependencies_parsed_at":"2022-08-30T06:00:28.165Z","dependency_job_id":null,"html_url":"https://github.com/jacklinquan/microbmp","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacklinquan%2Fmicrobmp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacklinquan%2Fmicrobmp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacklinquan%2Fmicrobmp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacklinquan%2Fmicrobmp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jacklinquan","download_url":"https://codeload.github.com/jacklinquan/microbmp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239136726,"owners_count":19587869,"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":["bmp","image","micropython","python"],"created_at":"2025-02-17T04:30:30.129Z","updated_at":"2025-02-17T04:30:31.037Z","avatar_url":"https://github.com/jacklinquan.png","language":"Python","funding_links":["https://www.paypal.me/jacklinquan"],"categories":[],"sub_categories":[],"readme":"# microbmp\n[![PayPal Donate][paypal_img]][paypal_link]\n[![PyPI version][pypi_img]][pypi_link]\n[![Downloads][downloads_img]][downloads_link]\n[![Documentation Status][docs_img]][docs_link]\n\n  [paypal_img]: https://github.com/jacklinquan/images/blob/master/paypal_donate_badge.svg\n  [paypal_link]: https://www.paypal.me/jacklinquan\n  [pypi_img]: https://badge.fury.io/py/microbmp.svg\n  [pypi_link]: https://badge.fury.io/py/microbmp\n  [downloads_img]: https://pepy.tech/badge/microbmp\n  [downloads_link]: https://pepy.tech/project/microbmp\n  [docs_img]: https://readthedocs.org/projects/microbmp/badge/?version=latest\n  [docs_link]: https://microbmp.readthedocs.io/en/latest/?badge=latest\n\nA small Python module for BMP image processing.\n \nIt supports BMP image of 1/2/4/8/24-bit colour depth.\n\nLoading supports compression method:\n\n- 0(BI_RGB, no compression)\n- 1(BI_RLE8, RLE 8-bit/pixel)\n- 2(BI_RLE4, RLE 4-bit/pixel)\n\nSaving only supports compression method 0(BI_RGB, no compression).\n\n## Installation\n`pip install microbmp`\n\n## Usage\n```Python\n\u003e\u003e\u003e from microbmp import MicroBMP\n\u003e\u003e\u003e img_24b_2x2 = MicroBMP(2, 2, 24)  # Create a 2(width) by 2(height) 24-bit image.\n\u003e\u003e\u003e img_24b_2x2.palette  # 24-bit image has no palette.\n\u003e\u003e\u003e img_24b_2x2.parray  # Pixels are arranged horizontally (top-down) in RGB order.\nbytearray(b'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00')\n\u003e\u003e\u003e img_24b_2x2[1, 1] = 255, 255, 255  # Access 1 pixel (R, G, B): img[x, y]\n\u003e\u003e\u003e img_24b_2x2[0, 1, 0] = 255  # Access 1 primary colour of 1 pixel (Red): img[x, y, c]\n\u003e\u003e\u003e img_24b_2x2[1, 0, 1] = 255  # (Green)\n\u003e\u003e\u003e img_24b_2x2[0, 0, 2] = 255  # (Blue)\n\u003e\u003e\u003e img_24b_2x2.save(\"img_24b_2x2.bmp\")\n70\n\u003e\u003e\u003e new_img_24b_2x2 = MicroBMP().load(\"img_24b_2x2.bmp\")\n\u003e\u003e\u003e new_img_24b_2x2.palette\n\u003e\u003e\u003e new_img_24b_2x2.parray\nbytearray(b'\\x00\\x00\\xff\\x00\\xff\\x00\\xff\\x00\\x00\\xff\\xff\\xff')\n\u003e\u003e\u003e print(new_img_24b_2x2)\nBMP image, RGB, 24-bit, 2x2 pixels, 70 bytes\n\u003e\u003e\u003e img_1b_3x2 = MicroBMP(3, 2, 1)  # Create a 3(width) by 2(height) 1-bit image.\n\u003e\u003e\u003e img_1b_3x2.palette  # Each colour is in the order of (R, G, B)\n[bytearray(b'\\x00\\x00\\x00'), bytearray(b'\\xff\\xff\\xff')]\n\u003e\u003e\u003e img_1b_3x2.parray  # Each bit stores the colour index in HLSB format.\nbytearray(b'\\x00')\n\u003e\u003e\u003e \" \".join([f\"{bin(byte)[2:]:0\u003e8}\" for byte in img_1b_3x2.parray])\n'00000000'\n\u003e\u003e\u003e img_1b_3x2[1, 0] = 1  # Access 1 pixel (index): img[x, y]\n\u003e\u003e\u003e img_1b_3x2[1, 1] = 1\n\u003e\u003e\u003e img_1b_3x2[2, 1] = 1\n\u003e\u003e\u003e img_1b_3x2.save(\"img_1b_3x2.bmp\")\n70\n\u003e\u003e\u003e new_img_1b_3x2 = MicroBMP().load(\"img_1b_3x2.bmp\")\n\u003e\u003e\u003e new_img_1b_3x2.palette\n[bytearray(b'\\x00\\x00\\x00'), bytearray(b'\\xff\\xff\\xff')]\n\u003e\u003e\u003e new_img_1b_3x2.parray\nbytearray(b'L')\n\u003e\u003e\u003e \" \".join([f\"{bin(b)[2:]:0\u003e8}\" for b in new_img_1b_3x2.parray])\n'01001100'\n\u003e\u003e\u003e print(new_img_1b_3x2)\nBMP image, indexed, 1-bit, 3x2 pixels, 70 bytes\n```\n\n## Change\n- Version 0.3.0\n    - Implementation of palette and pixels storage is changed from list to bytearray.\n    - API for pixel accessing is changed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacklinquan%2Fmicrobmp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacklinquan%2Fmicrobmp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacklinquan%2Fmicrobmp/lists"}