{"id":15049302,"url":"https://github.com/dloebl/cgif","last_synced_at":"2025-05-16T15:08:06.325Z","repository":{"id":40319673,"uuid":"378709850","full_name":"dloebl/cgif","owner":"dloebl","description":"GIF encoder written in C","archived":false,"fork":false,"pushed_at":"2025-02-09T13:18:31.000Z","size":433,"stargazers_count":126,"open_issues_count":5,"forks_count":15,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-05-16T12:42:05.240Z","etag":null,"topics":["animation","c","c99","compression","encoder","fast","file-format","gif","gif89a","graphics","image","library","lightweight","lzw","picture","size-optimization","video"],"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/dloebl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2021-06-20T18:04:14.000Z","updated_at":"2025-05-13T17:12:53.000Z","dependencies_parsed_at":"2025-04-12T14:19:17.483Z","dependency_job_id":"04393610-f5e1-4cc8-8dab-57284aeb74e3","html_url":"https://github.com/dloebl/cgif","commit_stats":{"total_commits":175,"total_committers":11,"mean_commits":"15.909090909090908","dds":0.4742857142857143,"last_synced_commit":"c234bc27d4012548faa13798c203219b59b77b09"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dloebl%2Fcgif","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dloebl%2Fcgif/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dloebl%2Fcgif/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dloebl%2Fcgif/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dloebl","download_url":"https://codeload.github.com/dloebl/cgif/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254553958,"owners_count":22090417,"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":["animation","c","c99","compression","encoder","fast","file-format","gif","gif89a","graphics","image","library","lightweight","lzw","picture","size-optimization","video"],"created_at":"2024-09-24T21:19:38.792Z","updated_at":"2025-05-16T15:08:01.316Z","avatar_url":"https://github.com/dloebl.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/cgif.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened\u0026can=1\u0026q=proj:cgif)\n## CGIF, a GIF encoder written in C\n\nA fast and lightweight GIF encoder that can create GIF animations and images. Summary of the main features:\n- user-defined global or local color-palette with up to 256 colors (limit of the GIF format)\n- size-optimizations for GIF animations:\n  - option to set a pixel to transparent if it has identical color in the previous frame (transparency optimization)\n  - do encoding just for the rectangular area that differs from the previous frame (width/height optimization)\n- fast: a GIF with 256 colors and 1024x1024 pixels can be created in below 50 ms even on a minimalistic system\n- MIT license (permissive)\n- different options for GIF animations: static image, N repetitions, infinite repetitions\n- additional source-code for verifying the encoder after making changes\n- user-defined delay time from one frame to the next (can be set independently for each frame)\n- source-code conforms to the C99 standard\n\n## Examples\nTo get started, we suggest that you have a look at our code examples. ```examples/cgif_example_video.c``` is an example that creates a GIF animation. ```examples/cgif_example.c``` is an example for a static GIF image.\n\n## Overview\nTo get an overview of the API, we recommend having a look at our wiki (https://github.com/dloebl/cgif/wiki/General-API) where types and functions are described. The corresponding implementations can be found in ```src/cgif.c``` and ```src/cgif_raw.c```. Here the most important types and functions:\n\n```C\n// These are the four struct types that contain all GIF data and parameters:\ntypedef CGIF_Config               // global cofinguration parameters of the GIF\ntypedef CGIF_FrameConfig          // local configuration parameters for a frame\ntypedef CGIF                     // struct for the full GIF\ntypedef CGIF_Frame               // struct for a single frame\n\n// The user needs only these three functions to create a GIF image:\nCGIF* cgif_newgif   (CGIF_Config* pConfig);                   // creates a new GIF\nint  cgif_addframe  (CGIF* pGIF, CGIF_FrameConfig* pConfig);  // adds a frame to an existing GIF\nint  cgif_close     (CGIF* pGIF);                           // close the created file and free memory\n```\n\nWith our encoder you can create animated or static GIFs, you can or cannot use certain optimizations, and so on. You can switch between all these different options easily using the two attributes ```attrFlags``` and ```genFlags``` in the configurations ```CGIF_Config``` and ```CGIF_FrameConfig```. These attributes are of type ```uint32_t``` and bundle yes/no-options with a bit-wise logic. So far only a few of the 32 bits are used leaving space to include further functionalities ensuring backward compatibility. We provide the following flag settings which can be combined by bit-wise or-operations:\n```C\nCGIF_ATTR_IS_ANIMATED              // make an animated GIF (default is non-animated GIF)\nCGIF_ATTR_NO_GLOBAL_TABLE          // disable global color table (global color table is default)\nCGIF_ATTR_HAS_TRANSPARENCY         // first entry in color table contains transparency (alpha channel)\nCGIF_ATTR_NO_LOOP                  // run GIF animation only one time. numLoops is ignored (no repetitions)\nCGIF_GEN_KEEP_IDENT_FRAMES         // keep frames that are identical to previous frame (default is to drop them)\nCGIF_FRAME_ATTR_USE_LOCAL_TABLE    // use a local color table for a frame (not used by default)\nCGIF_FRAME_ATTR_HAS_ALPHA          // frame contains alpha channel (index set via transIndex field)\nCGIF_FRAME_ATTR_HAS_SET_TRANS      // transparency setting provided by user (transIndex field)\nCGIF_FRAME_ATTR_INTERLACED         // encode frame interlaced\nCGIF_FRAME_GEN_USE_TRANSPARENCY    // use transparency optimization (size optimization)\nCGIF_FRAME_GEN_USE_DIFF_WINDOW     // do encoding just for the sub-window that changed (size optimization)\n```\nIf you didn't understand the point of ```attrFlags``` and ```genFlags``` and the flags, please don't worry. The example files ```examples/cgif_example.c``` and ```examples/cgif_example_video.c``` are all you need to get started and the used default settings for ```attrFlags``` and ```genFlags``` cover most cases quite well.\n\n## Compiling the example\nAn example can be compiled and tested simply by:\n```\n$ c99 -o cgif_example -Iinc examples/cgif_example_video.c src/cgif.c src/cgif_raw.c\n$ ./cgif_example\n\n```\n\n## Validating the encoder\nIn the folder ```tests```, we provide several testing routines that you can run via the script ```tests/performtests.sh```. To perform the tests you need to install the programs [ImageMagick](https://github.com/ImageMagick/ImageMagick), [gifsicle](https://github.com/kohler/gifsicle) and [tcc (tiny c compiler)](https://bellard.org/tcc/). \nWith the provided tests you can validate that the encoder still generates correct GIF files after making changes on the encoder itself.\n\n## Further explanations\nThe GIF format employs the [Lempel-Ziv-Welch (LZW)](https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch) algorithm for image compression. If you are interested in details of the GIF format, please have a look at the official GIF documentation (https://www.w3.org/Graphics/GIF/spec-gif89a.txt).\n\n## Versioning scheme\nReleases of cgif follow the semantic versioning scheme as described here: [semver.org](https://semver.org/)\n\nThe following additional guarantees are provided:\n* Public API of versions 0.x.x are stable.\n\n## Debugging\nThere is a Visual Studio Code debug configuration with launch targets for the two examples. You need to install the C/C++ extension and a LLDB extension (debugger) to debug cgif.\n\n## License\nLicensed under the MIT license (permissive).\nFor more details please see ```LICENSE```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdloebl%2Fcgif","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdloebl%2Fcgif","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdloebl%2Fcgif/lists"}