{"id":26949619,"url":"https://github.com/catdad-experiments/heic-convert","last_synced_at":"2025-05-15T02:03:35.771Z","repository":{"id":50309364,"uuid":"234686629","full_name":"catdad-experiments/heic-convert","owner":"catdad-experiments","description":"🤳 convert heic/heif images to jpeg and png","archived":false,"fork":false,"pushed_at":"2024-12-02T04:35:23.000Z","size":46,"stargazers_count":280,"open_issues_count":9,"forks_count":28,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-15T02:03:20.730Z","etag":null,"topics":["convert","heic","heic-to-jpg","heic-to-png","heif","image","jpg","npm-module","png"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/catdad-experiments.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2020-01-18T05:28:35.000Z","updated_at":"2025-05-12T10:10:29.000Z","dependencies_parsed_at":"2024-12-05T18:02:04.055Z","dependency_job_id":null,"html_url":"https://github.com/catdad-experiments/heic-convert","commit_stats":{"total_commits":41,"total_committers":3,"mean_commits":"13.666666666666666","dds":0.04878048780487809,"last_synced_commit":"28b88595f860328b88b9d188136782ebf21e5f04"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catdad-experiments%2Fheic-convert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catdad-experiments%2Fheic-convert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catdad-experiments%2Fheic-convert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catdad-experiments%2Fheic-convert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/catdad-experiments","download_url":"https://codeload.github.com/catdad-experiments/heic-convert/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254259369,"owners_count":22040819,"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":["convert","heic","heic-to-jpg","heic-to-png","heif","image","jpg","npm-module","png"],"created_at":"2025-04-02T22:16:48.364Z","updated_at":"2025-05-15T02:03:35.715Z","avatar_url":"https://github.com/catdad-experiments.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# heic-convert\n\n\u003e Convert HEIC/HEIF images to JPEG and PNG\n\n[![ci][ci.svg]][ci.link]\n[![npm-downloads][npm-downloads.svg]][npm.link]\n[![npm-version][npm-version.svg]][npm.link]\n\n[ci.svg]: https://github.com/catdad-experiments/heic-convert/actions/workflows/ci.yml/badge.svg\n[ci.link]: https://github.com/catdad-experiments/heic-convert/actions/workflows/ci.yml\n[npm-downloads.svg]: https://img.shields.io/npm/dm/heic-convert.svg\n[npm.link]: https://www.npmjs.com/package/heic-convert\n[npm-version.svg]: https://img.shields.io/npm/v/heic-convert.svg\n\n## Install\n\n```bash\nnpm install heic-convert\n```\n\n## Usage\n\nYou can convert the first image in a HEIC, or convert all images in the file. In both cases, the options are the same.\n\n### options object\n\n* `buffer` - a Node [`Buffer`](https://nodejs.org/api/buffer.html) or a [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) - the HEIC image to convert\n* `format` - string - either `JPEG` or `PNG`\n* `quality` - number between `0` and `1`, optional - the lossy compression quality to be used when converting to jpeg.\n\n## Usage in NodeJS\n\nConvert the main image in a HEIC to JPEG\n\n```javascript\nconst { promisify } = require('util');\nconst fs = require('fs');\nconst convert = require('heic-convert');\n\n(async () =\u003e {\n  const inputBuffer = await promisify(fs.readFile)('/path/to/my/image.heic');\n  const outputBuffer = await convert({\n    buffer: inputBuffer,\n    format: 'JPEG',\n    quality: 1\n  });\n\n  await promisify(fs.writeFile)('./result.jpg', outputBuffer);\n})();\n```\n\nConvert the main image in a HEIC to PNG\n\n```javascript\nconst { promisify } = require('util');\nconst fs = require('fs');\nconst convert = require('heic-convert');\n\n(async () =\u003e {\n  const inputBuffer = await promisify(fs.readFile)('/path/to/my/image.heic');\n  const outputBuffer = await convert({\n    buffer: inputBuffer,\n    format: 'PNG'\n  });\n\n  await promisify(fs.writeFile)('./result.png', outputBuffer);\n})();\n```\n\nConvert all images in a HEIC\n\n```javascript\nconst { promisify } = require('util');\nconst fs = require('fs');\nconst convert = require('heic-convert');\n\n(async () =\u003e {\n  const inputBuffer = await promisify(fs.readFile)('/path/to/my/image.heic');\n  const images = await convert.all({\n    buffer: inputBuffer,\n    format: 'JPEG'\n  });\n\n  for (let idx in images) {\n    const image = images[idx];\n    const outputBuffer = await image.convert();\n    await promisify(fs.writeFile)(`./result-${idx}.jpg`, outputBuffer);\n  }\n})();\n```\n\nThe work to convert an image is done when calling `image.convert()`, so if you only need one of the images in a multi-image file, you can convert just that one from the `images` array and skip doing any work for the remaining images.\n\n_Note that while the converter returns a Promise and is overall asynchronous, a lot of work is still done synchronously, so you should consider using a worker thread in order to not block the main thread in highly concurrent production environments._\n\n## Usage in the browser\n\nWhile the NodeJS version of `heic-convert` may be compiled for use in the browser with something like `webpack`, [not all build tools necessarily like to compile all modules well](https://github.com/catdad-experiments/heic-convert/issues/29). However, what further complicates things is that this module uses pure-javascript implementations of a jpeg and png encoder. But the browser has its own native encoders! Let's just use those instead of including a ton of extra code in your bundle.\n\nWhen compiling a client-side project, use:\n\n```javascript\nconst convert = require('heic-convert/browser');\n```\n\nThis is currently only supported in the main thread. Support for workers may be added in the future, but if you need it sooner, please create an issue or even a PR!\n\n## Related\n\n* [heic-cli](https://github.com/catdad-experiments/heic-cli) - convert heic/heif images to jpeg or png from the command line\n* [heic-decode](https://github.com/catdad-experiments/heic-decode) - decode heic images to raw image data\n* [libheif-js](https://github.com/catdad-experiments/libheif-js) - libheif as a pure-javascript npm module\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatdad-experiments%2Fheic-convert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcatdad-experiments%2Fheic-convert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatdad-experiments%2Fheic-convert/lists"}