{"id":15805303,"url":"https://github.com/k0lb3/etcpak","last_synced_at":"2025-04-15T18:17:49.461Z","repository":{"id":40992625,"uuid":"347659254","full_name":"K0lb3/etcpak","owner":"K0lb3","description":"a python wrapper for etcpak","archived":false,"fork":false,"pushed_at":"2024-11-27T10:11:11.000Z","size":123,"stargazers_count":7,"open_issues_count":1,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T18:17:27.718Z","etag":null,"topics":["dxt","dxtc","etc","python","python-c-api","texture"],"latest_commit_sha":null,"homepage":"","language":"C++","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/K0lb3.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":"2021-03-14T14:27:55.000Z","updated_at":"2025-01-21T07:28:39.000Z","dependencies_parsed_at":"2024-09-17T22:25:18.487Z","dependency_job_id":"9884881d-96ba-4a5e-97ac-1ff6de8b8e21","html_url":"https://github.com/K0lb3/etcpak","commit_stats":{"total_commits":31,"total_committers":5,"mean_commits":6.2,"dds":0.6129032258064516,"last_synced_commit":"1677656060120e480c38b0802ec66b773b5db735"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K0lb3%2Fetcpak","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K0lb3%2Fetcpak/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K0lb3%2Fetcpak/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K0lb3%2Fetcpak/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/K0lb3","download_url":"https://codeload.github.com/K0lb3/etcpak/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249125998,"owners_count":21216705,"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":["dxt","dxtc","etc","python","python-c-api","texture"],"created_at":"2024-10-05T02:08:02.953Z","updated_at":"2025-04-15T18:17:49.455Z","avatar_url":"https://github.com/K0lb3.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# etcpak\n\n[![PyPI supported Python versions](https://img.shields.io/pypi/pyversions/etcpak.svg)](https://pypi.python.org/pypi/etcpak)\n[![Win/Mac/Linux](https://img.shields.io/badge/platform-windows%20%7C%20macos%20%7C%20linux-informational)]()\n[![MIT](https://img.shields.io/pypi/l/etcpak.svg)](https://github.com/K0lb3/etcpak/blob/master/LICENSE)\n[![Test](https://github.com/K0lb3/etcpak/actions/workflows/test.yml/badge.svg)](https://github.com/K0lb3/etcpak/actions/workflows/test.yml)\n[![Build \u0026 Publish wheels](https://github.com/K0lb3/etcpak/actions/workflows/release.yml/badge.svg)](https://github.com/K0lb3/etcpak/actions/workflows/release.yml)\n\nA python wrapper for [wolfpld/etcpak](https://github.com/wolfpld/etcpak)\nAll relevant function  and class documentation was taken from [wolfpld/etcpak](https://github.com/wolfpld/etcpak).\n\n1. [Installation](https://github.com/K0lb3/etcpak#installation)\n2. [Example](https://github.com/K0lb3/etcpak#example)\n3. [Functions](https://github.com/K0lb3/etcpak#functions)\n\n## Installation\n\n```cmd\npip install etcpak\n```\n\nor download/clone the git and use\n\n```cmd\npython setup.py install\n```\n\n## Example\n\n```python\nfrom PIL import Image\nimport etcpak\n\n# load image\nimg = Image.open(file_path)\n\n# get image data\nimg_data = img.convert(\"RGBA\").tobytes()\n\n# compress data\ncompressed = etcpak.compress_bc3(img_data, img.width, img.height)\n```\n\n__composite image for format comparission__\n```python\nimport os\nimport etcpak\nimport texture2ddecoder\nfrom PIL import Image\n\nFORMATS = [\n    (\"DXT1\", etcpak.compress_bc1, texture2ddecoder.decode_bc1),\n    (\"DXT1 Dither\", etcpak.compress_bc1_dither, texture2ddecoder.decode_bc1),\n    (\"DXT5\", etcpak.compress_bc3, texture2ddecoder.decode_bc3),\n    (\"ETC1\", etcpak.compress_etc1_rgb, texture2ddecoder.decode_etc1),\n    (\"ETC1 Dither\", etcpak.compress_etc1_rgb_dither, texture2ddecoder.decode_etc1),\n    (\"ETC2 RGB\", etcpak.compress_etc2_rgb, texture2ddecoder.decode_etc2),\n    (\"ETC2 RGBA\", etcpak.compress_etc2_rgba, texture2ddecoder.decode_etc2a8)\n]\n\np = \"S:\\\\Pictures\"\nfor fp in os.listdir(p):\n    if not fp[-4:] in [\".png\", \".jpg\", \".bmp\", \"jpeg\"]:\n        continue\n    # load image and adjust format and size\n    print(fp)\n    img = Image.open(os.path.join(p, fp)).convert(\"RGBA\")\n    img = img.crop((0,0,img.width-img.width%4, img.height-img.height%4))\n    \n    # create composite image\n    comp = Image.new(\"RGBA\", (img.width*8, img.height))\n    comp.paste(img, (0, 0))\n    print(img.width * img.height * 4)\n\n    # iterate over all formats\n    for i, (name, enc, dec) in enumerate(FORMATS):\n        print(name)\n        # make sure that the channel order is correct for the compression\n        if name[:3] == \"DXT\":\n            raw = img.tobytes()\n        elif name[:3] == \"ETC\":\n            r,g,b,a = img.split()\n            raw = Image.merge('RGBA', (b,g,r,a)).tobytes()\n        \n        # compress\n        data = enc(raw, img.width, img.height)\n\n        # decompress\n        dimg = Image.frombytes(\"RGBA\", img.size, dec(data, img.width, img.height), \"raw\", \"BGRA\")\n\n        # add to composite image\n        comp.paste(dimg, (img.width*(i+1), 0))\n\n    # save composite image\n    comp.save(os.path.splitext(fp)[0]+\".png\")\n```\n\n## Functions\n\n* all functions accept only arguments, no keywords\n* **the data has to be RGBA/BGRA for the RGB functions as well**\n* **all __DXT__ compressions require data in the __RGBA__ format**\n* **all __ETC__ compressions require data in the __BGRA__ format**\n\nsee [etcpak/__init__.pyi](./etcpak/__init__.pyi)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk0lb3%2Fetcpak","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fk0lb3%2Fetcpak","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk0lb3%2Fetcpak/lists"}