{"id":21998531,"url":"https://github.com/systemrage/iconolatry","last_synced_at":"2025-04-30T21:43:11.690Z","repository":{"id":41558676,"uuid":"117890929","full_name":"SystemRage/Iconolatry","owner":"SystemRage","description":"Converter (encode / decode) for .ICO files","archived":false,"fork":false,"pushed_at":"2021-02-26T22:30:03.000Z","size":1472,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-30T20:11:24.927Z","etag":null,"topics":["conversion","converter","cur","cur-files","cursor","decoder","encoder","favicon","icns","ico","ico-files","icon","icons","image-processing","python","reader","writer"],"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/SystemRage.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":"2018-01-17T20:47:58.000Z","updated_at":"2025-01-15T13:09:05.000Z","dependencies_parsed_at":"2022-09-01T14:51:02.023Z","dependency_job_id":null,"html_url":"https://github.com/SystemRage/Iconolatry","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SystemRage%2FIconolatry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SystemRage%2FIconolatry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SystemRage%2FIconolatry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SystemRage%2FIconolatry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SystemRage","download_url":"https://codeload.github.com/SystemRage/Iconolatry/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251789225,"owners_count":21644077,"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":["conversion","converter","cur","cur-files","cursor","decoder","encoder","favicon","icns","ico","ico-files","icon","icons","image-processing","python","reader","writer"],"created_at":"2024-11-29T22:25:13.803Z","updated_at":"2025-04-30T21:43:11.663Z","avatar_url":"https://github.com/SystemRage.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Iconolatry\n\u003e *Advanced Icon Converter*\n\n## Why\nThere are several online converters, icon makers and favicon generators that can \ntransform image formats in `.ico` files or to achieve reverse process,\nbut only a few of them are really working and none of these provides an API.\nSo i developped a pure python small library, not using external software (like *ImageMagick*), \nto perform the above operations.\n\n## Features\n- Gives detailed info about conversion process.\n- You can use it as bare module inside your projects or running it with CLI commands. \n\n- Reads `.ico` and `.cur` formats:\n   - You can decode a single icon / cursor, a list of icon / cursor(s), a folder, a list of folders, or mixing...\n   - You can decode icon / cursor(s) as bytes stream(s) too.\n   - You can select output paths, output file names, output file formats (all those supported by *PIL*) for every conversion process.\n   - Supports decoding multi-size and / or multi-depth icons.\n   - Checks if the image *AND* mask is correct, otherwise is recomputed if needs.\n\n- Writes `.ico` and `.cur` using a set of images (whose formats are supported by *PIL*):\n   - You can convert a single image, a list of images, a folder, a list of folders, or mixing...\n   - You can select output paths, output file names, output file formats (`.ico`, `.cur`) for every conversion process.\n   - You can generate `.ico` multi-format (packing many images with different sizes and depths).\n   - You can provide fixed resize values or automatically let to resize input images to the nearest standard icon size.\n   - You can provide hotspots for `.cur` conversions.\n   - You can provide custom palettes to apply during conversion (for indexed images).\n\n## Requirements\n   - `Python 3+`\n   - `PIL (Pillow)`\n\n## Options\n\n### Encoder\n\n|    Parameter      | CLI |       Type      |                                      Description                                                    |\n|-------------------|-----|-----------------|-----------------------------------------------------------------------------------------------------|\n| `paths_images`    | `-i`| list of lists   | every list can contain one/more image(s) path(s) and/or one/more folder image(s) path(s) to convert |\n| `paths_icocur`    | `-o`| list            | contains output path(s) for every resulting conversion. If isn't defined, working directory is used |\n| `names_icocur`    | `-n`| list            | contains output name(s) for every resulting conversion. If `paths_images` contains a *folder path* and corresponding `names_icocur` is defined, a multi-`.ico` is created, otherwise every image in *folder path* is converted to a single `.ico`/`.cur` |\n| `formats_icocur`  | `-f`| list            | contains format(s) for every resulting conversion (*'.ico'* or *'.cur'*). If `.cur`, can be specified hotspot x (integer) and hotspot y (integer) using a tuple; example: *('.cur', 2, 5)* |\n| `type_resize`     | `-r`| string or tuple | with *'up256_prop'* dimensions \u003e256 pixels are resized keeping global image aspect ratio, with *'up256_no_prop'* dimensions \u003e256 pixels are resized without keeping global image aspect ratio, with *'square'* dimensions are resized to nearest            square standard size, with a tuple *(width, height)* for a custom resize |\n| `custom_palettes` | `-p`| dict            | the key is a tuple *(mode, bitdepth)*, the value can be a list of RGB tuples *[(R1,G1,B1),...,(Rn,Bn,Gn)]* (usual palette format) or a flat list *[V1,V2,...,Vn]* (compact format for grayscale palette) or a `.gpl` file path |\n\n### Decoder\n\n|    Parameter     | CLI | Type |                                      Description                                                  |\n|------------------|-----|------|---------------------------------------------------------------------------------------------------|\n| `paths_icocurs`  | `-i`| list | contains one/more icon/cursor(s) path(s) and/or one/more folder icon/cursor(s) path(s) to convert |\n| `paths_image`    | `-o`| list | contains output path(s) for every resulting conversion. If isn't defined, working directory is used |\n| `names_image`    | `-n`| list | contains output name(s) for every resulting conversion |\n| `formats_image`  | `-f`| list | contains format(s) for every resulting conversion (all saving PIL formats) |\n| `rebuild`        | `-u`| bool | if *True*, recompute mask from the alpha channel data |\n\n## Usage Examples\n\n### How to write an `.ico`.\n```python\n\u003e\u003e\u003e conv = Encode([['/path/input/test0.png']], paths_icocur = ['/path/output'], names_icocur = ['myname'], formats_icocur = ['.ico'],\n                  type_resize = (48, 28))\n\u003e\u003e\u003e conv.all_icocur_written\n{'/path/output/myname.ico': [{'file': '/path/input/test0.png', 'mode': 'grayscale', 'depth': 1, 'size': '32 x 32', 'resize': '48 x 28'}]}\n```\n```\npython3 Iconolatry.py encode -i /path/input/test0.png -o /path/output -n myname -f .ico -r \"(48, 28)\"\n```\n\n### How to write a `.cur`.\n```python\n\u003e\u003e\u003e conv = Encode([['/path/input/test0.png']], paths_icocur = ['/path/output'], names_icocur = ['myname'], formats_icocur = [('.cur', 2, 5)],\n                  custom_palettes = {('1', 1) : '/path/palettes/custom1bit.gpl')\n\u003e\u003e\u003e conv.all_icocur_written\n{'/path/output/myname.cur': [{'file': '/path/input/test0.png', 'mode': 'grayscale', 'depth': 1, 'size': '32 x 32'}]}\n```\n```\npython3 Iconolatry.py encode -i /path/input/test0.png -o /path/output -n myname -f \"('.cur', 2, 5)\" -p \"{('1', 1) : '/path/palettes/custom1bit.gpl'}\"\n```\n\n#### How to write a multi-`.ico`.\n```python\n\u003e\u003e\u003e conv = Encode([['/path/input/test0.png', '/path/input/test1.bmp', '/path/input/test2.jpg']], paths_icocur = [''],\n                  names_icocur = [''], formats_icocur = ['.ico'])\n\u003e\u003e\u003e conv.all_icocur_written\n{'/path/working/directory/multi.ico': [{'file': '/path/input/test0.png', 'mode': 'grayscale', 'depth': 1, 'size': '32 x 32'}, {'file': '/path/input/test1.bmp', 'mode': 'grayscale', 'depth': 4, 'size': '48 x 48'}, {'file': '/path/input/test2.jpg', 'mode': 'grayscale', 'depth': 8, 'size': '16 x 16'}]\n}\n```\nNote how the *multi* name is auto-assigned because `names_icocur` isn't setted.\n```\npython3 Iconolatry.py encode -i /path/input/test0.png /path/input/test1.bmp /path/input/test2.jpg -f .ico\n```\n\n#### How to write more `.ico`s and/or `.cur`s together.\n```python\n\u003e\u003e\u003e conv = Encode([['/path/input/test0.png', '/path/input/test1.png'], ['/path/input/test2.png']], \n                  paths_icocur = ['/path/outputA', '/path/outputB'],\n                  names_icocur = ['test01', 'test2'],\n                  formats_icocur = ['.ico', '.cur'])\n\u003e\u003e\u003e conv.all_icocur_written\n{'/path/outputA/test01.ico': [{'file': '/path/input/test0.png', 'mode': 'grayscale', 'depth': 1, 'size': '32 x 32'}, {'file': '/path/input/test1.png', 'mode': 'grayscale', 'depth': 4, 'size': '48 x 48'}], \n'/path/outputB/test2.cur': [{'file': '/path/input/test2.png', 'mode': 'grayscale', 'depth': 8, 'size': '16 x 16'}]\n}\n```\n```\npython3 Iconolatry.py encode -i /path/input/test0.png /path/input/test1.png -o /path/outputA -i /path/input/test2.png -o /path/outputB\n-n test01 test2 -f .ico .cur\n```\n\n#### How to encode image folders.\n```python\n\u003e\u003e\u003e conv = Encode([['/path/input/folder'], ['/path/input/folder']], paths_icocur = ['/path/outputA', '/path/outputB'], \n                    names_icocur = ['mymultico', ''],\n                    formats_icocur = ['.ico', '.cur'])\n\u003e\u003e\u003e conv.all_icocur_written\n{'/path/outputA/mymulti.ico': [{'file': '/path/input/folder/test0.png', 'mode': 'grayscale', 'depth': 1, 'size': '32 x 32'}, {'file': '/path/input/folder/test1.png', 'mode': 'grayscale', 'depth': 4, 'size': '48 x 48'}, {'file': '/path/input/folder/test2.png', 'mode': 'grayscale', 'depth': 8, 'size': '16 x 16'}],\n'/path/outputB/test0.cur': [{'file': '/path/input/folder/test0.png', 'mode': 'grayscale', 'depth': 1, 'size': '32 x 32', 'hotspot_x': 0, 'hotspot_y': 0}], \n'/path/outputB/test1.cur': [{'file': '/path/input/folder/test1.png', 'mode': 'grayscale', 'depth': 4, 'size': '48 x 48', 'hotspot_x': 0, 'hotspot_y': 0}], \n'/path/outputB/test2.cur': [{'file': '/path/input/folder/test2.png', 'mode': 'grayscale', 'depth': 8, 'size': '16 x 16', 'hotspot_x': 0, 'hotspot_y': 0}]\n}\n```\n```\npython3 Iconolatry.py encode -i /path/input/folder -o /path/outputA -n mymultico -f .ico -i /path/input/folder -o /path/outputB -f .cur\n```\n\n#### How to read more `.ico` and/or `.cur` together.\n```python\n\u003e\u003e\u003e conv = Decode(['/path/input/cursor.cur', '/path/input/multicon.ico'], paths_image = [''], names_image = [''], formats_image = ['.png', '.bmp'])\n\n\u003e\u003e\u003e conv.all_icocur_readed\n{'/path/input/cursor.cur': {'image_0': {'im_obj': \u003cPIL.Image.Image image mode=RGBA size=32x32 at 0x7FDEF936C780\u003e, 'depth': 32, 'hotspot_x': 0, 'hotspot_y': 0, 'saved': '/path/working/directory/cursor.png'}}, \n'/path/input/multicon.ico': {'image_0': {'im_obj': \u003cPIL.Image.Image image mode=RGBA size=16x16 at 0x7FDEF936C860\u003e, 'depth': 1, 'saved': '/path/working/directory/multicon_0.bmp'}, 'image_1': {'im_obj': \u003cPIL.Image.Image image mode=RGBA size=32x32 at 0x7FDEF936C630\u003e, 'depth': 24, 'saved': '/path/working/directory/multicon_1.bmp'}, 'image_2': {'im_obj': \u003cPIL.Image.Image image mode=RGBA size=48x48 at 0x7FDEF936C4A8\u003e, 'depth': 32, 'saved': '/path/working/directory/multicon_2.bmp'}}\n}\n```\n```\npython3 Iconolatry.py decode -i /path/input/cursor.cur /path/input/multicon.ico -f .png .bmp\n```\n\n#### How to decode image folders.\n```python\n\u003e\u003e\u003e conv = Decode(['/path/input/folder'], paths_image = ['/path/outputA'], names_image = ['customname'], rebuild = True)\n\n\u003e\u003e\u003e conv.all_icocur_readed\n{'/path/input/folder/test0.cur': {'image_0': {'im_obj': \u003cPIL.Image.Image image mode=RGBA size=16x16 at 0x7FDFDE8E52E8\u003e, 'depth': 1, 'hotspot_x': 0, 'hotspot_y': 0, 'saved': '/path/outputA/customname_0.png'}}, \n'/path/input/folder/test1.cur': {'image_0': {'im_obj': \u003cPIL.Image.Image image mode=RGBA size=48x48 at 0x7FDFDE8E5438\u003e, 'depth': 32, 'hotspot_x': 0, 'hotspot_y': 0, 'saved': '/path/outputA/customname_1.png'}}, \n'/path/input/folder/test2.cur': {'image_0': {'im_obj': \u003cPIL.Image.Image image mode=RGBA size=32x32 at 0x7FDFDE8E5860\u003e, 'depth': 24, 'hotspot_x': 0, 'hotspot_y': 0, 'saved': '/path/outputA/customname_2.png'}}, \n'/path/input/folder/testymulti.ico': {'image_0': {'im_obj': \u003cPIL.Image.Image image mode=RGBA size=16x16 at 0x7FDFDE8E5240\u003e, 'depth': 1, 'saved': '/path/outputA/customname_3.png'}, 'image_1': {'im_obj': \u003cPIL.Image.Image image mode=RGBA size=48x48 at 0x7FDFDE8E5B70\u003e, 'depth': 32, 'saved': '/path/outputA/customname_4.png'}, 'image_2': {'im_obj': \u003cPIL.Image.Image image mode=RGBA size=32x32 at 0x7FDFDE8E5C18\u003e, 'depth': 24, 'saved': '/path/outputA/customname_5.png'}}\n}\n```\n```\npython3 Iconolatry.py decode -i /path/input/folder -o /path/outputA -n customname -u\n```\n\n## License\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/SystemRage/Iconolatry/blob/master/LICENSE) ©  Matteo ℱan\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsystemrage%2Ficonolatry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsystemrage%2Ficonolatry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsystemrage%2Ficonolatry/lists"}