{"id":22291322,"url":"https://github.com/maestroerror/go-libheif","last_synced_at":"2025-10-18T13:57:58.656Z","repository":{"id":171415247,"uuid":"647875176","full_name":"MaestroError/go-libheif","owner":"MaestroError","description":" GoLang wrapper for the libheif library, providing easy-to-use APIs for HEIC to JPEG/PNG conversions and vice versa.","archived":false,"fork":false,"pushed_at":"2024-04-11T16:07:27.000Z","size":7385,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"maestro","last_synced_at":"2024-06-19T13:39:34.302Z","etag":null,"topics":["avif","golang","golang-library","heic","heic-to-jpeg","heic-to-png","heif","libheif"],"latest_commit_sha":null,"homepage":"","language":"Go","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/MaestroError.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":"2023-05-31T17:57:48.000Z","updated_at":"2024-05-08T03:07:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"ee88fc0d-84e7-47a7-9a8c-ebde8514372a","html_url":"https://github.com/MaestroError/go-libheif","commit_stats":null,"previous_names":["maestroerror/go-libheif"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaestroError%2Fgo-libheif","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaestroError%2Fgo-libheif/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaestroError%2Fgo-libheif/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaestroError%2Fgo-libheif/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MaestroError","download_url":"https://codeload.github.com/MaestroError/go-libheif/tar.gz/refs/heads/maestro","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227962204,"owners_count":17847915,"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":["avif","golang","golang-library","heic","heic-to-jpeg","heic-to-png","heif","libheif"],"created_at":"2024-12-03T17:16:46.729Z","updated_at":"2025-10-18T13:57:58.568Z","avatar_url":"https://github.com/MaestroError.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-libheif\n\nGoLang wrapper for the libheif library, providing easy-to-use APIs for HEIC to JPEG/PNG conversions and vice versa (Also provides support for AVIF to JPEG/PNG conversions).  \n This package was originally developed to support the [php-heic-to-jpg](https://github.com/MaestroError/php-heic-to-jpg) package, which had [problems](https://github.com/MaestroError/php-heic-to-jpg/issues/15) while converting some HEIF images.\n\n#### Implementation:\n\n- For a swift start, consider browsing our [quickstart guide](https://medium.com/@revaz.gh/using-the-go-libheif-module-for-converting-images-between-the-heic-format-and-other-popular-formats-e7829165c368) on Medium.\n- If you're primarily interested in a hassle-free image conversion tool, we have already integrated this module into a Command Line Interface (CLI) application and a docker image, available [here](https://github.com/MaestroError/heif-converter-image).\n\n### Prerequisites\n\nYou need to install [libheif](https://github.com/strukturag/libheif) before using this module. You can check the [strukturag/libheif](https://github.com/strukturag/libheif) for installation instructions, but as I have found, the easiest way for me was to use [brew](https://brew.sh/):\n\n```bash\nbrew install cmake make pkg-config x265 libde265 libjpeg libtool\nbrew install libheif\n```\n\n_Note: Pay attention to the brew's recommendation while installing_\n\nYou can find installation scripts in [heif-converter-image](https://github.com/MaestroError/heif-converter-image) repository with names:\n\n- install-libheif.sh\n- install-libheif-macos.sh\n- install-libheif-windows.bat\n\n_If the installation process seems a bit challenging, we recommend to consider using the [heif-converter-image](https://github.com/MaestroError/heif-converter-image) which offers a ready-to-use docker image._\n\n### Installation\n\n```bash\ngo get github.com/MaestroError/go-libheif\n```\n\n### Usage\n\nThis library provides functions to convert images between HEIC format and other common formats such as JPEG and PNG.\n\nTo convert an image from HEIC / HEIF / AVIF to JPEG or PNG:\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\n\t\"github.com/MaestroError/go-libheif\"\n)\n\nfunc main() {\n\terr := libheif.HeifToJpeg(\"input.heic\", \"output.jpeg\", 80)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\terr = libheif.HeifToPng(\"input.heic\", \"output.png\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n\n```\n\nTo convert an image from HEIC to `image.Image` and process image:\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"image/png\"\n\n\t\"github.com/MaestroError/go-libheif\"\n)\n\nfunc main() {\n\timg, err := libheif.ReturnImageFromHeif(\"input.heic\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n    err = png.Encode(os.Stdout, img)\n    if err != nil {\n      t.Errorf(\"Failed to encode image: %v\", err)\n    }\n\n}\n\n```\n\n_Note: It finds hard to convert some jpeg and png files to heic, see libheif_test.go:14 for details_\n\nTo convert an image from HEIC / HEIF / AVIF to JPEG or PNG:\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\n\t\"github.com/MaestroError/go-libheif\"\n)\n\nfunc main() {\n\terr := libheif.HeifToJpeg(\"input.heic\", \"output.jpeg\", 80)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\terr = libheif.HeifToPng(\"input.heic\", \"output.png\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n\n```\n\nTo save an image as HEIC:\n\n```go\npackage main\n\nimport (\n\t\"image\"\n\t\"log\"\n\n\t\"github.com/MaestroError/go-libheif\"\n)\n\nfunc main() {\n\timg := image.NewRGBA(image.Rect(0, 0, 100, 100))\n\terr := libheif.SaveImageAsHeif(img, \"png\", \"output.heic\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n\n```\n\n_Note: Quality for **HeifToJpeg** function and image format for **SaveImageAsHeif** function should be provided. The quality value ranges from 1 to 100 inclusive, higher values meaning better quality. The format for **SaveImageAsHeif** is the format of the original image._\n\nPlease consult the GoDoc [documentation](https://pkg.go.dev/github.com/MaestroError/go-libheif) for more detailed information about the provided functions and their usage.\n\n### Contributions\n\nContributions to `go-libheif` are wholeheartedly encouraged! We believe in the power of the open source community to build the most robust and accessible projects. Whether you are a seasoned Go developer or just getting started, your perspective and efforts can help improve this project for everyone.\n\nHere are a few ways you might contribute:\n\n- Bug Fixes: If you encounter a problem with go-libheif, please open an issue in the GitHub repository. Even better, if you can solve the issue, we welcome pull requests.\n- New Features: Interested in expanding the capabilities of go-libheif? Please open an issue to discuss your idea before starting on the code. Once we've agreed on an approach, you can submit a pull request with your new feature.\n- Documentation: Clear documentation is vital to any project. If you can clarify our instructions or add helpful examples, we would appreciate your input.\n\nHere are the steps for contributing code:\n\n- Fork the go-libheif repository and clone it to your local machine.\n- Create a new branch for your changes.\n- Make your changes and push them to your fork.\n- Open a pull request from your fork's branch to the go-libheif main branch.\n\nPlease remember to be as detailed as possible in your pull request descriptions to help the maintainers understand your changes.\nWe look forward to seeing what you contribute! Together, we can make go-libheif even better.\n\n### Credits\n\nThanks to @strukturag and @farindk (Dirk Farin) for his work on the [libheif](https://github.com/strukturag/libheif) library 🙏\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaestroerror%2Fgo-libheif","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaestroerror%2Fgo-libheif","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaestroerror%2Fgo-libheif/lists"}