[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-84175":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":9,"totalLinesOfCode":9,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":9,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":17,"stars30d":17,"stars90d":16,"forks30d":16,"starsTrendScore":18,"compositeScore":19,"rankGlobal":9,"rankLanguage":9,"license":9,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":20,"hasPages":20,"topics":9,"createdAt":9,"pushedAt":9,"updatedAt":22,"readmeContent":23,"aiSummary":9,"trendingCount":16,"starSnapshotCount":16,"syncStatus":24,"lastSyncTime":25,"discoverSource":26},84175,"libheif","strukturag\u002Flibheif","strukturag","libheif is an HEIF and AVIF file format decoder and encoder.",null,"https:\u002F\u002Fgithub.com\u002Fstrukturag\u002Flibheif","C++",2249,381,42,242,0,1,3,29.75,false,"main","2026-06-12 02:04:38","# libheif\n\n[![Build Status](https:\u002F\u002Fgithub.com\u002Fstrukturag\u002Flibheif\u002Fworkflows\u002Fbuild\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fstrukturag\u002Flibheif\u002Factions) [![Build Status](https:\u002F\u002Fci.appveyor.com\u002Fapi\u002Fprojects\u002Fstatus\u002Fgithub\u002Fstrukturag\u002Flibheif?svg=true)](https:\u002F\u002Fci.appveyor.com\u002Fproject\u002Fstrukturag\u002Flibheif) [![Coverity Scan Build Status](https:\u002F\u002Fscan.coverity.com\u002Fprojects\u002F16641\u002Fbadge.svg)](https:\u002F\u002Fscan.coverity.com\u002Fprojects\u002Fstrukturag-libheif)\n\nlibheif is an ISO\u002FIEC 23008-12 HEIF and AVIF (AV1 Image File Format) file format decoder and encoder.\nHEIC and AVIF are new image file formats employing HEVC (H.265) or AV1 image coding, respectively, for the\nbest compression ratios currently possible.\n\nOn top of HEIC and AVIF, libheif also supports HEIF images coded with VVC, AVC, JPEG, JPEG-2000, and ISO\u002FIEC 23001-17.\nThe ISO\u002FIEC 23001-17 codec is built-in to libheif and allows to store lossless images and video in many different formats.\n\nlibheif makes use of various codec libraries for implementing each compression format.\nFor HEIC, [libde265](https:\u002F\u002Fgithub.com\u002Fstrukturag\u002Flibde265) is used by default for decoding and x265 for encoding.\nFor AVIF, libaom, dav1d, svt-av1, or rav1e are used as codecs.\nlibheif can be built with a subset of the supported codecs to keep the size and the number of dependencies low.\nAlternatively, the libheif codecs can also be built as separate plugins that can be installed and loaded dynamically when used.\n\n## Supported features\n\nlibheif has support for:\n\n* HEIC, AVIF, VVC, AVC, JPEG-in-HEIF, JPEG2000, uncompressed (ISO\u002FIEC 23001-17:2024) codecs\n* alpha channels, depth maps, thumbnails, auxiliary images\n* multiple images in a file\n* HEIF image sequences and MP4 video, including alpha channels\n* tiled images with decoding individual tiles and encoding tiled images by adding tiles one after another\n* HDR images, correct color transform according to embedded color profiles\n* image transformations (crop, mirror, rotate), overlay images\n* plugin interface to add alternative codecs\n* reading EXIF and XMP metadata\n* region annotations and mask images\n* streaming of images and video by requesting data from the network through a data-reader interface\n\nSupported codecs:\n| Format       |  Decoders           |  Encoders                    |\n|:-------------|:-------------------:|:----------------------------:|\n| HEIC         | libde265, ffmpeg    | x265, kvazaar                |\n| AVIF         | libaom, dav1d       | libaom, rav1e, svt-av1       |\n| VVC          | vvdec               | vvenc, uvg266                |\n| AVC          | openh264, ffmpeg    | x264                         |\n| JPEG         | libjpeg(-turbo)     | libjpeg(-turbo)              |\n| JPEG2000     | OpenJPEG            | OpenJPEG                     |\n| HTJ2K        | OpenJPEG            | OpenJPH                      |\n| uncompressed | built-in            | built-in                     |\n\n## Programming API\n\nThe library has a C API for easy integration and wide language support.\n\nThe decoder automatically supports both HEIF and AVIF (and the other compression formats) through the same API. The same decoding code can be used to decode any of them.\nThe encoder can be switched between HEIF and AVIF simply by setting `heif_compression_HEVC` or `heif_compression_AV1`\nto `heif_context_get_encoder_for_format()`, or using any of the other compression formats.\n\n### Loading the primary image from a HEIF file\n\n```C\nheif_context* ctx = heif_context_alloc();\nheif_context_read_from_file(ctx, input_filename, nullptr);\n\n\u002F\u002F get a handle to the primary image\nheif_image_handle* handle;\nheif_context_get_primary_image_handle(ctx, &handle);\n\n\u002F\u002F decode the image and convert colorspace to RGB, saved as 24bit interleaved\nheif_image* img;\nheif_decode_image(handle, &img, heif_colorspace_RGB, heif_chroma_interleaved_RGB, nullptr);\n\nint stride;\nconst uint8_t* data = heif_image_get_plane_readonly(img, heif_channel_interleaved, &stride);\n\n\u002F\u002F ... process data as needed ...\n\n\u002F\u002F clean up resources\nheif_image_release(img);\nheif_image_handle_release(handle);\nheif_context_free(ctx);\n```\n\n### Writing a HEIF file\n\n```C\nheif_context* ctx = heif_context_alloc();\n\n\u002F\u002F get the default encoder\nheif_encoder* encoder;\nheif_context_get_encoder_for_format(ctx, heif_compression_HEVC, &encoder);\n\n\u002F\u002F set the encoder parameters\nheif_encoder_set_lossy_quality(encoder, 50);\n\n\u002F\u002F encode the image\nheif_image* image; \u002F\u002F code to fill in the image omitted in this example\nheif_context_encode_image(ctx, image, encoder, nullptr, nullptr);\n\nheif_encoder_release(encoder);\n\nheif_context_write_to_file(ctx, \"output.heic\");\n\nheif_context_free(ctx);\n```\n\n### Get the EXIF data from a HEIF file\n\n```C\nheif_item_id exif_id;\n\nint n = heif_image_handle_get_list_of_metadata_block_IDs(image_handle, \"Exif\", &exif_id, 1);\nif (n==1) {\n  size_t exifSize = heif_image_handle_get_metadata_size(image_handle, exif_id);\n  uint8_t* exifData = malloc(exifSize);\n  struct heif_error error = heif_image_handle_get_metadata(image_handle, exif_id, exifData);\n}\n```\n\n### Image sequences, MP4 video\n\nSee the [image sequences API documentation](https:\u002F\u002Fgithub.com\u002Fstrukturag\u002Flibheif\u002Fwiki\u002FReading-and-Writing-Sequences).\n\nSince HEIF image sequences are very similar to MP4 video, libheif can also read and write MP4 video (without audio)\nwith all supported codecs.\n\n### High-resolution tiled images\n\nFor very large resolution images, it is not always feasible to process the whole image.\nIn this case, `libheif` can process the image tile by tile.\nSee the [image tiling API documentation](https:\u002F\u002Fgithub.com\u002Fstrukturag\u002Flibheif\u002Fwiki\u002FReading-and-Writing-Tiled-Images).\n\n### More documenation\n\nSee the header files for the complete C API.\n\nThere is also a C++ API which is a header-only wrapper to the C API.\nHence, you can use the C++ API and still be binary compatible.\nCode using the C++ API is much less verbose than using the C API directly.\n\n\n## Compiling\n\nThis library uses the CMake build system (the earlier autotools build files have been removed in v1.16.0).\n\nFor a minimal configuration, we recommend to use the codecs libde265 and x265 for HEIC and AOM for AVIF.\nMake sure that you compile and install [libde265](https:\u002F\u002Fgithub.com\u002Fstrukturag\u002Flibde265)\nfirst, so that the configuration script will find this.\nAlso install x265 and its development files if you want to use HEIF encoding, but note that x265 is GPL.\nAn alternative to x265 is kvazaar (BSD).\n\nThe basic build steps are as follows (--preset argument needs CMake >= 3.21):\n\n````sh\nmkdir build\ncd build\ncmake --preset=release ..\nmake\n````\n\nThere are CMake presets to cover the most frequent use cases.\n\n* `release`: the preferred preset which compiles all codecs as separate plugins.\n  If you do not want to distribute some of these plugins (e.g. HEIC), you can omit packaging these.\n* `release-noplugins`: this is a smaller, self-contained build of libheif without using the plugin system.\n  A single library is built with support for HEIC and AVIF.\n* `testing`: for building and executing the unit tests. Also the internal library symbols are exposed. Do not use for distribution.\n* `fuzzing`: all codecs like in release build, but configured into a self-contained library with enabled fuzzers. The library should not distributed.\n\nYou can optionally adapt these standard configurations to your needs.\nThis can be done, for example, by calling `ccmake .` from within the `build` directory.\n\n### CMake configuration variables\n\nLibheif supports many different codecs. In order to reduce the number of dependencies and the library size,\nyou can choose which of these codecs to include. Each codec can be compiled either as built-in to the library\nwith a hard dependency, or as a separate plugin file that is loaded dynamically.\n\nFor each codec, there are two configuration variables:\n\n* `WITH_{codec}`: enables the codec\n* `WITH_{codec}_PLUGIN`: when enabled, the codec is compiled as a separate plugin.\n\nIn order to use dynamic plugins, also make sure that `ENABLE_PLUGIN_LOADING` is enabled.\nThe placeholder `{codec}` can have these values: `LIBDE265`, `X265`, `AOM_DECODER`, `AOM_ENCODER`, `SvtEnc`, `DAV1D`, `OpenH264`, `X264`, `FFMPEG_DECODER`, `JPEG_DECODER`, `JPEG_ENCODER`, `KVAZAAR`, `OpenJPEG_DECODER`, `OpenJPEG_ENCODER`, `OPENJPH_ENCODER`, `VVDEC`, `VVENC`, `UVG266`, `WEBCODECS`.\n\nFurther options are:\n\n* `WITH_UNCOMPRESSED_CODEC`: enable support for uncompressed images according to ISO\u002FIEC 23001-17:2024. This is *experimental*\n   and not available as a dynamic plugin. When enabled, it adds a dependency to `zlib`, and optionally will use `brotli`.\n* `WITH_HEADER_COMPRESSION`: enables support for compressed metadata. When enabled, it adds a dependency to `zlib`.\n   Note that header compression is not widely supported yet.\n* `WITH_LIBSHARPYUV`: enables high-quality YCbCr\u002FRGB color space conversion algorithms (requires `libsharpyuv`,\n   e.g. from the `third-party` directory).\n* `ENABLE_EXPERIMENTAL_FEATURES`: enables functions that are currently in development and for which the API is not stable yet\n   and may contain security risks. When this is enabled, a header `heif_experimental.h` will be installed that contains this\n   unstable API. Distributions should not enable this in release or production builds.\n* `ENABLE_MULTITHREADING_SUPPORT`: can be used to disable any multithreading support, e.g. for embedded platforms.\n* `ENABLE_PARALLEL_TILE_DECODING`: when enabled, libheif will decode tiled images in parallel to speed up compilation.\n* `PLUGIN_DIRECTORY`: the directory where libheif will search for dynamic plugins when the environment\n  variable `LIBHEIF_PLUGIN_PATH` is not set.\n* `WITH_REDUCED_VISIBILITY`: only export those symbols into the library that are public API.\n  Has to be turned off for running some tests.\n\n### macOS\n\n1. Install dependencies with Homebrew\n\n    ```sh\n    brew install cmake make pkg-config x265 libde265 libjpeg libtool\n    ```\n\n2. Configure and build project (--preset argument needs CMake >= 3.21):\n\n    ```sh\n    mkdir build\n    cd build\n    cmake --preset=release ..\n    .\u002Fconfigure\n    make\n    ```\n\n### Windows\n\nYou can build and install libheif using the [vcpkg](https:\u002F\u002Fgithub.com\u002FMicrosoft\u002Fvcpkg\u002F) dependency manager:\n\n```sh\ngit clone https:\u002F\u002Fgithub.com\u002FMicrosoft\u002Fvcpkg.git\ncd vcpkg\n.\u002Fbootstrap-vcpkg.bat\n.\u002Fvcpkg integrate install\n.\u002Fvcpkg install libheif\n```\n\nThe libheif port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https:\u002F\u002Fgithub.com\u002FMicrosoft\u002Fvcpkg) on the vcpkg repository.\n\n### Adding libaom encoder\u002Fdecoder for AVIF\n\n* Run the `aom.cmd` script in the `third-party` directory to download libaom and\n  compile it.\n\nWhen running `cmake` or `configure`, make sure that the environment variable\n`PKG_CONFIG_PATH` includes the absolute path to `third-party\u002Faom\u002Fdist\u002Flib\u002Fpkgconfig`.\n\n### Adding rav1e encoder for AVIF\n\n* Install `cargo`.\n* Install `cargo-c` by executing\n\n```sh\ncargo install --force cargo-c\n```\n\n* Run the `rav1e.cmd` script in the `third-party` directory to download rav1e\n  and compile it.\n\nWhen running `cmake`, make sure that the environment variable\n`PKG_CONFIG_PATH` includes the absolute path to `third-party\u002Frav1e\u002Fdist\u002Flib\u002Fpkgconfig`.\n\n### Adding dav1d decoder for AVIF\n\n* Install [`meson`](https:\u002F\u002Fmesonbuild.com\u002F).\n* Run the `dav1d.cmd` script in the `third-party` directory to download dav1d\n  and compile it.\n\nWhen running `cmake`, make sure that the environment variable\n`PKG_CONFIG_PATH` includes the absolute path to `third-party\u002Fdav1d\u002Fdist\u002Flib\u002Fx86_64-linux-gnu\u002Fpkgconfig`.\n\n### Adding SVT-AV1 encoder for AVIF\n\nYou can either use the SVT-AV1 encoder libraries installed in the system or use a self-compiled current version.\nIf you want to compile SVT-AV1 yourself,\n\n* Run the `svt.cmd` script in the `third-party` directory to download SVT-AV1\n  and compile it.\n\nYou have to enable SVT-AV1 with CMake.\n\nWhen running `cmake`, make sure that the environment variable\n`PKG_CONFIG_PATH` includes the absolute path to `third-party\u002FSVT-AV1\u002FBuild\u002Flinux\u002Finstall\u002Flib\u002Fpkgconfig`.\nYou may have to replace `linux` in this path with your system's identifier.\n\n## Codec plugins\n\nStarting with v1.14.0, each codec backend can be compiled statically into libheif or as a dynamically loaded plugin.\nYou can choose this individually for each codec backend in the CMake settings using `WITH_{codec}_PLUGIN` options.\nCompiling a codec backend as dynamic plugin will generate a shared library that is installed in the system together with libheif.\nThe advantage is that only the required plugins have to be installed and libheif has fewer dependencies.\n\nThe plugins are loaded from the colon-separated (semicolon-separated on Windows) list of directories stored in the environment variable `LIBHEIF_PLUGIN_PATH`.\nIf this variable is empty, they are loaded from a directory specified in the CMake configuration.\nYou can also add plugin directories programmatically.\n\n### Codec specific notes\n\n* The FFMPEG decoding plugin can make use of h265 hardware decoders. However, it currently (v1.17.0, ffmpeg v4.4.2) does not work\n  correctly with all streams. Thus, libheif still prefers the libde265 decoder if it is available.\n\n* The \"webcodecs\" HEVC decoder can only be used in emscripten builds since it uses the web-browser's API. For the same reason, it is not available as a plugin.\n\n## Usage\n\nlibheif comes with a set of command line tools:\n* `heif-dec` for decoding HEIF images to JPEG or PNG. It can also decode image sequences or MP4 video.\n* `heif-enc` for encoding JPEG, PNG, TIFF, or Y4M images to HEIF images, image sequences or MP4 video.\n* `heif-info` for getting some overview information about the HEIF file or (using the `-d` option) to dump the full box structure of the file.\n* `heif-view` for displaying HEIF image sequences\n\n### `heif-enc` command line tool\n\nYou can find more documentation for the `heif-enc` tool on the [wiki page](https:\u002F\u002Fgithub.com\u002Fstrukturag\u002Flibheif\u002Fwiki\u002Fheif%E2%80%90enc-Command-Line-Tool).\n\n### Security limits\n\nLibheif defines some security limits that prevent that very large images exceed the available memory or malicious input files can be used for a denial-of-service attack.\nWhen you are programming against the libheif API and you need to process very large images, you can set the `heif_security_limits` individually.\nWhen using `heif-dec`, there is the option to switch off security limits with `--disable-limits`.\nIn case a third-party software is using libheif, but does not give you a way to switch off the limits, you can set an environment variable `LIBHEIF_SECURITY_LIMITS=off` to switch it off globally.\nClearly, only do this if you know what you are doing and you are sure not to process malicious files.\n\n## Encoder benchmark\n\nA current benchmark of the AVIF encoders (as of 14 Oct 2022) can be found on the Wiki page\n[AVIF encoding benchmark](https:\u002F\u002Fgithub.com\u002Fstrukturag\u002Flibheif\u002Fwiki\u002FAVIF-Encoder-Benchmark).\n\n## Language bindings\n\n* .NET Platform (C#, F#, and other languages): [libheif-sharp](https:\u002F\u002Fgithub.com\u002F0xC0000054\u002Flibheif-sharp)\n* C++: part of libheif\n* Go: [libheif-go](https:\u002F\u002Fgithub.com\u002Fstrukturag\u002Flibheif-go), the wrapper distributed with libheif is deprecated\n* JavaScript: by compilation with emscripten (see below)\n* NodeJS module: [libheif-js](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Flibheif-js)\n* Python: [pyheif](https:\u002F\u002Fpypi.org\u002Fproject\u002Fpyheif\u002F), [pillow_heif](https:\u002F\u002Fpypi.org\u002Fproject\u002Fpillow-heif\u002F)\n* Rust: [libheif-sys](https:\u002F\u002Fgithub.com\u002FCykooz\u002Flibheif-sys)\n* Swift: [libheif-Xcode](https:\u002F\u002Fswiftpackageregistry.com\u002FSDWebImage\u002Flibheif-Xcode)\n* JavaFX: [LibHeifFx](https:\u002F\u002Fgithub.com\u002Flanthale\u002FLibHeifFX)\n\nLanguages that can directly interface with C libraries (e.g., Swift, C#) should work out of the box.\n\n## Compiling to JavaScript \u002F WASM\n\nlibheif can also be compiled to JavaScript using\n[emscripten](http:\u002F\u002Fkripken.github.io\u002Femscripten-site\u002F).\nIt can be built like this (in the libheif directory):\n````\nmkdir buildjs\ncd buildjs\nUSE_WASM=0 ..\u002Fbuild-emscripten.sh ..\n````\nSet `USE_WASM=1` to build with WASM output.\nSee the `build-emscripten.sh` script for further options.\n\n## Online demo\n\nCheck out this [online demo](https:\u002F\u002Fstrukturag.github.io\u002Flibheif\u002F).\nThis is `libheif` running in JavaScript in your browser.\n\n## Example programs\n\nSome example programs are provided in the `examples` directory.\nThe program `heif-dec` converts all images stored in an HEIF\u002FAVIF file to JPEG or PNG.\n`heif-enc` lets you convert JPEG files to HEIF\u002FAVIF.\nThe program `heif-info` is a simple, minimal decoder that dumps the file structure to the console.\n\nFor example convert `example.heic` to JPEGs and one of the JPEGs back to HEIF:\n\n```sh\ncd examples\u002F\n.\u002Fheif-dec example.heic example.jpeg\n.\u002Fheif-enc example-1.jpeg -o example.heif\n```\n\nIn order to convert `example-1.jpeg` to AVIF use:\n\n```sh\n.\u002Fheif-enc example-1.jpeg -A -o example.avif\n```\n\nThere is also a GIMP plugin using libheif [here](https:\u002F\u002Fgithub.com\u002Fstrukturag\u002Fheif-gimp-plugin).\n\n## HEIF\u002FAVIF thumbnails for the Gnome desktop\n\nThe program `heif-thumbnailer` can be used as an HEIF\u002FAVIF thumbnailer for the Gnome desktop.\nThe matching Gnome configuration files are in the `gnome` directory.\nPlace the files `heif.xml` and `avif.xml` into `\u002Fusr\u002Fshare\u002Fmime\u002Fpackages` and `heif.thumbnailer` into `\u002Fusr\u002Fshare\u002Fthumbnailers`.\nYou may have to run `update-mime-database \u002Fusr\u002Fshare\u002Fmime` to update the list of known MIME types.\n\n## gdk-pixbuf loader\n\nlibheif also includes a gdk-pixbuf loader for HEIF\u002FAVIF images. 'make install' will copy the plugin\ninto the system directories. However, you will still have to run `gdk-pixbuf-query-loaders --update-cache`\nto update the gdk-pixbuf loader database.\n\n## Software using libheif\n\n* [GIMP](https:\u002F\u002Fwww.gimp.org\u002F)\n* [Krita](https:\u002F\u002Fkrita.org)\n* [ImageMagick](https:\u002F\u002Fimagemagick.org\u002F)\n* [GraphicsMagick](http:\u002F\u002Fwww.graphicsmagick.org\u002F)\n* [darktable](https:\u002F\u002Fwww.darktable.org)\n* [digiKam 7.0.0](https:\u002F\u002Fwww.digikam.org\u002F)\n* [libvips](https:\u002F\u002Fgithub.com\u002Flibvips\u002Flibvips)\n* [kImageFormats](https:\u002F\u002Fapi.kde.org\u002Fframeworks\u002Fkimageformats\u002Fhtml\u002Findex.html)\n* [libGD](https:\u002F\u002Flibgd.github.io\u002F)\n* [Kodi HEIF image decoder plugin](https:\u002F\u002Fkodi.wiki\u002Fview\u002FAdd-on:HEIF_image_decoder)\n* [bimg](https:\u002F\u002Fgithub.com\u002Fh2non\u002Fbimg)\n* [GDAL](https:\u002F\u002Fgdal.org\u002Fdrivers\u002Fraster\u002Fheif.html)\n* [OpenImageIO](https:\u002F\u002Fsites.google.com\u002Fsite\u002Fopenimageio\u002F)\n* [XnView](https:\u002F\u002Fwww.xnview.com)\n\n## Packaging status\n\n[![libheif packaging status](https:\u002F\u002Frepology.org\u002Fbadge\u002Fvertical-allrepos\u002Flibheif.svg?exclude_unsupported=1&columns=3&exclude_sources=modules,site&header=libheif%20packaging%20status)](https:\u002F\u002Frepology.org\u002Fproject\u002Flibheif\u002Fversions)\n\n## Sponsors\n\nSince I work as an independent developer, I need your support to be able to allocate time for libheif.\nYou can [sponsor](https:\u002F\u002Fgithub.com\u002Fsponsors\u002Ffarindk) the development using the link in the right hand column.\n\nA big thank you goes to these major sponsors for supporting the development of libheif:\n\n* AOMedia\n* OGC (Open Geospatial Consortium)\n* Pinterest\n* Shopify \u003Cimg src=\"logos\u002Fsponsors\u002Fshopify.svg\" alt=\"shopify-logo\" height=\"20\"\u002F>\n* StrukturAG\n\n## License\n\nThe libheif is distributed under the terms of the GNU Lesser General Public License.\nThe sample applications are distributed under the terms of the MIT License.\n\nSee COPYING for more details.\n\nCopyright (c) 2017-2020 Struktur AG\u003C\u002Fbr>\nCopyright (c) 2017-2026 Dirk Farin\u003C\u002Fbr>\nContact: Dirk Farin \u003Cdirk.farin@gmail.com>\n",2,"2026-06-11 04:12:29","trending"]