heic2any vs heic-convert
HEIC Image Conversion Comparison
3 Years
heic2anyheic-convert
What's HEIC Image Conversion?

HEIC (High Efficiency Image Coding) is a modern image format that provides better compression than JPEG while maintaining high image quality. However, not all devices and applications support HEIC files, making it necessary to convert them to more widely accepted formats like JPEG or PNG. This is where HEIC conversion libraries come into play. They provide tools to programmatically convert HEIC images to other formats, enabling compatibility with a broader range of devices and software. This is particularly useful for web applications, image processing tools, and any platform that needs to handle images from devices like iPhones, which use HEIC as their default format.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
heic2any229,083
7652.72 MB242 years agoMIT
heic-convert132,370
2927.92 kB102 years agoISC
Feature Comparison: heic2any vs heic-convert

Conversion Formats

  • heic2any:

    heic2any supports converting HEIC files to multiple formats, including JPEG, PNG, and WEBP. This flexibility allows developers to choose the output format based on their needs, making it a more versatile option for applications that require support for various image formats.

  • heic-convert:

    heic-convert primarily supports converting HEIC files to JPEG and PNG formats. It is focused on providing high-quality conversions with minimal configuration, making it easy to use for straightforward tasks.

Output Quality Control

  • heic2any:

    heic2any offers more comprehensive control over the output quality, especially for JPEG conversions. It allows developers to set quality parameters and provides better handling of different formats, making it a better choice for applications that require precise control over image quality.

  • heic-convert:

    heic-convert provides basic quality control for JPEG conversions, allowing users to specify the quality level (0-100) for the output images. However, it is relatively simple and does not offer advanced features for fine-tuning the output quality.

Batch Processing

  • heic2any:

    heic2any also supports batch processing, enabling the conversion of multiple HEIC files at once. Its ability to handle multiple formats in a single batch makes it a versatile choice for applications that need to process images in bulk.

  • heic-convert:

    heic-convert supports batch processing of HEIC files, allowing users to convert multiple images in a single operation. This feature is particularly useful for users who need to convert large batches of images quickly and efficiently.

Ease of Use: Code Examples

  • heic2any:

    heic2any provides a simple API for converting HEIC images, with good documentation that makes it easy to understand and use. Here’s an example of how to use it:

    import { heic2any } from 'heic2any';
    
    async function convertHEIC() {
      const file = document.getElementById('input').files[0];
      const outputBlob = await heic2any({
        blob: file,
        toType: 'image/png', // Output format
        quality: 0.8,
      });
    
      const url = URL.createObjectURL(outputBlob);
      document.getElementById('output').src = url;
    }
    
    convertHEIC();
    
  • heic-convert:

    heic-convert is known for its simplicity and ease of use. The API is straightforward, making it easy for developers to integrate into their applications quickly. Here’s a quick example:

    const heicConvert = require('heic-convert');
    
    async function convertHEIC() {
      const buffer = await fs.promises.readFile('image.heic');
      const outputBuffer = await heicConvert({
        buffer: buffer,
        format: 'JPEG', // Output format
        quality: 0.8, // Quality (0-1)
      });
    
      await fs.promises.writeFile('image.jpg', outputBuffer);
    }
    
    convertHEIC();
    
How to Choose: heic2any vs heic-convert
  • heic2any:

    Choose heic2any if you require a more versatile solution that supports converting HEIC to multiple formats (JPEG, PNG, WEBP) and offers better control over the output quality and format. It is ideal for applications that need more flexibility in handling different image formats.

  • heic-convert:

    Choose heic-convert if you need a simple, straightforward solution for converting HEIC images to JPEG or PNG with minimal setup. It is particularly useful for quick conversions and supports batch processing.

README for heic2any

HEIC2ANY

Demo, Documentation & more

Client-side (browser-side, using Javascript) conversion of HEIC/HEIF image files to JPEG, PNG, or GIF.

What is HEIC format?

High Efficiency Image File Format (HEIC) is a new image container format from the developers of MPEG, a popular audio and video compression standard. HEIC will be used by default on new photos on iOS 11, and it’s designed to save you storage space. As it’s a new container format, there will be some incompatibilities along the way, and Apple does a good job at handling most of these. iOS 11 will automatically share HEIC files as the default JPEG format for apps, so you won’t notice anything when you share a photo on Twitter or Instagram. iOS 11 also offers to automatically transfer photos and videos in a compatible format for Mac or PC users, useful if you’re simply plugging your iPhone into your laptop or PC. theverge.com

Why you might need it?

While developing some web-based application that should be able to handle mobile uploads, I've come across a problem where browsers can not display certain images uploaded from the iPhone, after investigating through the issue, I noticed that that my iPhone was giving a heic formatted image.

Currently there are zero web browsers that support HEIC photos. Even Apple's latest-greatest version of Safari can't decode HEIC and doesn't recognize the "image/heic" mimetype. A solution that came across my mind is to utilize the benefits of high resolution and low storage of heic images when storing in the server and client-side conversion to JPEG for viewing on the browser.

Usage and limitations

This library would typically be used for viewing purposes, as currently it's not focusing on copying any metadata from the original heic file to the output jpeg, gif or png. The development process of this library is focusing on viewing a browser-consumable version of an heic file, and doing it quickly, asynchronously (using web workers) and accurately. This library would even convert heic containers that have multiple heic images into an animated gif.

However, if you're planning on storing the files (not just viewing them), I'd suggest you look for a server-side tool, or you try to get your hands dirty and contribute to this library and make it capable of storing metadata.

Last but not least, this tool is specifically for the browser environment, it will not work in node environment.

Known issues

Those are the known issues of the library, pull requests are welcome:

  1. Library doesn't take any metadata from the original file, resulting file doesn't have any metadata.
  2. Library can convert bursts into an animated gif, however when a heic animation is given (like the stars animation in the demo) library will only take the first shot of the animation.
  3. Support for IE11 is not here yet.
  4. The library requires a browser-like environment to work, i.e. it needs the existence of the DOM and window object.