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-detect-converter

v0.0.8

Published

Automatically detect real HEIC images and convert to displayable JPG or PNG in the browser

Readme

heic-detect-converter

一个在 在浏览器中自动检测文件真实 HEIC 类型并转换为可显示的 JPG 或 PNG 的轻量工具。
用于解决 file.type 被错误标记为 image/png或者 image/jpeg 的情况

A lightweight utility that automatically detects real HEIC files in the browser and converts them to displayable JPG or PNG, even when the file.type is incorrectly labeled as image/png or image/jpeg.


✨ 功能特点 (Features)

  • ✅ 自动识别 HEIC 图片(即使 file.type 被错误标记为 image/png
  • ✅ 在浏览器端完成 HEIC → JPG/PNG 转换,无需后端处理
  • ✅ 输出格式自动判断:
    • 带透明度 → PNG
    • 不带透明度 → JPG
  • ✅ 支持 TypeScript 类型提示
  • ✅ 非图片会抛出异常,避免错误操作

  • ✅ Automatically detects HEIC images (even when reported as image/png)
  • ✅ Converts HEIC → JPG/PNG directly in the browser — no backend required
  • ✅ Smart format output:
    • Images with transparency → PNG
    • Images without transparency → JPG
  • ✅ Full TypeScript type support
  • ✅ Throws errors for non-image files to prevent misuse

📦 安装方式 (Installation)

npm install heic-detect-converter
# 或 or
yarn add heic-detect-converter
# 或 or
pnpm add heic-detect-converter

🚀 使用示例 (Usage Example)

ES Module

import convertHeicToImage from 'heic-detect-converter';

const handleFile = async (file: File) => {
	try {
		const output = await convertHeicToImage(file);
		console.log(output); // Blob
	} catch (err) {
		console.error(err);
		alert('文件不是图片或无法转换');
	}
};

CommonJS

const convertHeicToImage = require('heic-detect-converter');

async function handleFile(file) {
	try {
		const output = await convertHeicToImage(file);
		console.log(output); // Blob
	} catch (err) {
		console.error(err);
		alert('文件不是图片或无法转换');
	}
}