# heic-to

> Converting HEIF/HEIF image formats to PNG/JPEG in the browser

Latest version **1.5.2** (published 2026-05-26) · LGPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install heic-to
pnpm add heic-to
yarn add heic-to
bun add heic-to
```

## Health

**Score 55/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; large bundle.

## Facts

| | |
|---|---|
| Version | 1.5.2 |
| Published | 2026-05-26 |
| First published | 2024-08-07 |
| Weekly downloads | 0 |
| License | LGPL-3.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 23.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 351 |
| Author | Hopper Gee |
| Maintainers | hoppergee |
| Keywords | heic, heif, jpeg, jpg, png, conversion, convert, image, decoder |

## Links

- npm: https://www.npmjs.com/package/heic-to
- Repository: https://github.com/hoppergee/heic-to
- Issues: https://github.com/hoppergee/heic-to/issues
- npm.io page: https://npm.io/package/heic-to

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.5.2 (latest) — 2026-05-26
- 1.5.1 — 2026-05-26
- 1.5.0 — 2026-05-26
- 1.4.3 — 2026-05-19
- 1.4.2 — 2026-02-03
- 1.4.1 — 2026-02-03
- 1.4.0 — 2026-02-03
- 1.3.1 — 2026-02-03
- 1.3.0 — 2025-09-24
- 1.2.2 — 2025-08-13
- 1.2.1 — 2025-07-03
- 1.2.0 — 2025-07-03
- 1.1.14 — 2025-06-11
- 1.1.13 — 2025-05-07
- 1.1.12 — 2025-04-18
- … 16 more at https://npm.io/package/heic-to/versions

## README

# heic-to

Convert HEIC/HEIF images to JPEG, PNG in browser using Javascript.

Inspired by [heic2any](https://github.com/alexcorvi/heic2any) and [libheif-web](https://github.com/joutvhu/libheif-web). The purpose of heic-to is to continuously follow up on releases of [libheif](https://github.com/strukturag/libheif) to be able to preview HEIC/HEIF images in browser.

Currently, heic-to is using [libheif 1.22.2](https://github.com/strukturag/libheif/releases/tag/v1.22.2) under the hood. 

| Release  | libheif  |
| -------- | -------- |
| 1.5.2    | 1.22.2   | 
| 1.5.1    | 1.22.1   | 
| 1.5.0    | 1.22.0   | 
| 1.4.3    | 1.21.2   | 
| 1.4.2    | 1.21.2   | 
| 1.4.1    | 1.21.1   | 
| 1.4.0    | 1.21.0   | 
| 1.3.1    | 1.20.2   | 
| 1.3.0    | 1.20.2   | 
| 1.2.2    | 1.20.2   | 
| 1.2.1    | 1.20.1   | 
| 1.2.0    | 1.20.0   | 
| 1.1.14   | 1.19.8   | 
| 1.1.14   | 1.19.8   | 
| 1.1.13   | 1.19.8   | 
| 1.1.12   | 1.19.7   | 
| 1.1.11   | 1.19.7   | 
| 1.1.10   | 1.19.7   | 
| 1.1.9    | 1.19.7   | 
| 1.1.8    | 1.19.7   | 
| 1.1.7    | 1.19.6   | 
| 1.1.6    | 1.19.5   | 
| 1.1.5    | 1.19.5   | 
| 1.1.4    | 1.19.4   | 
| 1.1.3    | 1.19.3   | 
| 1.1.2    | 1.19.2   | 
| 1.1.1    | 1.19.1   | 
| 1.1.0    | 1.19.0   | 
| 1.0.3    | 1.18.2   |
| 1.0.2    | 1.18.2   |
| 1.0.1    | 1.18.2   |
| 1.0.0    | 1.18.1   |

### Demo

Try the [🌟 live demo](https://hoppergee.github.io/heic-to/example/).

### Usage

#### Check whether the image is HEIC or not 

```js
import { isHeic } from "heic-to"

const file = field.files[0]
await isHeic(file)
```

#### Convert HEIC to JPEG/PNG/Bitmap


```js
import { heicTo } from "heic-to"

const file = field.files[0]

const jpeg = await heicTo({
  blob: file,
  type: "image/jpeg",
  quality: 0.5
})

const png = await heicTo({
  blob: file,
  type: "image/png",
  quality: 0.5
})

const bitmap = await heicTo({
  blob: file,
  type: "bitmap",
  options: {
    imageOrientation: "flipY"
  }
})
```

#### Cotent Security Policy

When meets CSP issue like this:

```
Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive
```

Fix it by using `csp/heic-to` 

```diff
- import { heicTo } from "heic-to"
+ import { heicTo } from "heic-to/csp"
```

#### Access global variable with IIFE build

If you would like to access heic-to with pure JavaScript without package builder like with CDN.

```html
<script src="https://cdn.jsdelivr.net/npm/heic-to@1.5.2/dist/iife/heic-to.js"></script>
<script>
  /*...*/
  if (await HeicTo.isHeic(file)) {
    const jpeg = await HeicTo({
      blob: file,
      type: "image/jpeg",
      quality: 0.5
    })
    /*...*/
  }
  /*...*/
</script>
```

#### Call heic-to in web worker

If you want to call `heicTo` in web workers:

```diff
- import { heicTo } from "heic-to"
+ import { heicTo } from "heic-to/next"
```

### Development guide

#### How to fast test your changes on local?

```bash
yarn s
```

This will open `http://127.0.0.1:8080/example/` for easy testing.

#### How to build libheif.js from [libheif](https://github.com/strukturag/libheif) on Mac

```bash
brew install cmake make pkg-config x265 libde265 libjpeg libtool
brew install emscripten

git clone git@github.com:strukturag/libheif.git
```

Did below changes from `build-emscripten.sh`
```diff
# EXPORTED_FUNCTIONS=$($EMSDK/upstream/bin/llvm-nm $LIBHEIFA --format=just-symbols | grep "^heif_\|^de265_\|^aom_" | grep "[^:]$" | sed 's/^/_/' | paste -sd "," -)
EXPORTED_FUNCTIONS=$(/opt/homebrew/opt/llvm/bin/llvm-nm $LIBHEIFA --format=just-symbols | grep "^heif_\|^de265_\|^aom_" | grep "[^:]$" | sed 's/^/_/' | paste -sd "," -)
```

Start building
```bash
cd libheif
mkdir buildjs
cd buildjs
LIBDE265_VERSION=1.0.16 USE_WASM=0 ../build-emscripten.sh ..

# Or build without unsafe-eval
LIBDE265_VERSION=1.0.16 USE_UNSAFE_EVAL=0 USE_WASM=0 ../build-emscripten.sh ..
```

---
_Source: https://npm.io/package/heic-to · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
