npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

heic-converter

v1.0.0

Published

Convert HEIC images to PNG/JPEG entirely in the browser using libheif-js

Readme

heic-converter

Convert HEIC images to PNG/JPEG entirely in the browser using libheif-js.

Try the Live Demo

Features

  • Zero backend dependencies - Runs entirely in the browser using WebAssembly
  • Simple API - Clear function names and straightforward usage
  • TypeScript support - Full type definitions included
  • Multi-image support - Handle HEIC files with multiple images (bursts)
  • Privacy-focused - All processing happens client-side

Installation

npm install heic-converter

Quick Start

import { heicToPng, heicToJpeg } from 'heic-converter';

// Convert HEIC to PNG
const pngBlob = await heicToPng(heicFile);

// Convert HEIC to JPEG with quality setting
const jpegBlob = await heicToJpeg(heicFile, { quality: 0.8 });

Usage

Convert to PNG

import { heicToPng } from 'heic-converter';

const pngBlob = await heicToPng(heicFile);
const url = URL.createObjectURL(pngBlob);

Convert to JPEG

import { heicToJpeg } from 'heic-converter';

const jpegBlob = await heicToJpeg(heicFile, { quality: 0.92 });

Handle Multi-Image HEIC Files

HEIC files can contain multiple images (e.g., burst photos):

import { heicToPng } from 'heic-converter';

const pngBlobs = await heicToPng(heicFile, { multiple: true });
pngBlobs.forEach((blob, index) => {
  console.log(`Image ${index + 1}:`, blob);
});

Check if File is HEIC

import { isHeic } from 'heic-converter';

if (await isHeic(file)) {
  const pngBlob = await heicToPng(file);
}

Advanced Usage

import { convert } from 'heic-converter';

const blob = await convert(heicFile, {
  format: 'jpeg',
  quality: 0.95,
  multiple: false
});

API Reference

heicToPng(blob, options?)

Converts a HEIC image to PNG format.

| Parameter | Type | Description | |-----------|------|-------------| | blob | Blob | The HEIC image to convert | | options.multiple | boolean | Extract all images from multi-image HEIC files (default: false) |

Returns: Promise<Blob> or Promise<Blob[]> if multiple is true


heicToJpeg(blob, options?)

Converts a HEIC image to JPEG format.

| Parameter | Type | Description | |-----------|------|-------------| | blob | Blob | The HEIC image to convert | | options.quality | number | JPEG quality between 0 and 1 (default: 0.92) | | options.multiple | boolean | Extract all images from multi-image HEIC files (default: false) |

Returns: Promise<Blob> or Promise<Blob[]> if multiple is true


convert(blob, options)

Generic conversion function for advanced use cases.

| Parameter | Type | Description | |-----------|------|-------------| | blob | Blob | The HEIC image to convert | | options.format | 'png' \| 'jpeg' | Output format (required) | | options.quality | number | JPEG quality between 0 and 1 (default: 0.92, ignored for PNG) | | options.multiple | boolean | Extract all images from multi-image HEIC files (default: false) |

Returns: Promise<Blob> or Promise<Blob[]> if multiple is true


isHeic(blob)

Checks if a file is a HEIC/HEIF image by examining its file signature.

| Parameter | Type | Description | |-----------|------|-------------| | blob | Blob | The file to check |

Returns: Promise<boolean> - true if the file is HEIC/HEIF

TypeScript

Full TypeScript support with included type definitions:

import type { ConvertOptions, ConvertOptionsWithFormat } from 'heic-converter';

interface ConvertOptions {
  quality?: number;      // 0-1 for JPEG (default: 0.92)
  multiple?: boolean;    // Handle multi-image HEIC files (default: false)
}

interface ConvertOptionsWithFormat extends ConvertOptions {
  format: 'png' | 'jpeg';
}

Browser Support

Requires a modern browser with:

  • WebAssembly support
  • Canvas API
  • ES2020+ features

Supported browsers:

  • Chrome/Edge 87+
  • Firefox 89+
  • Safari 15+

How It Works

  1. Uses libheif-js (WebAssembly) to decode HEIC to raw image data
  2. Renders the decoded data to an HTML Canvas
  3. Exports the canvas as PNG or JPEG Blob
  4. All processing happens entirely in the browser - no server uploads

License

MIT

Contributing

Contributions are welcome! Please open an issue or pull request on GitHub.

Credits

Built with libheif-js, the WebAssembly build of libheif.