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 🙏

© 2025 – Pkg Stats / Ryan Hefner

jpg2bmp

v0.0.2

Published

A library for jpeg to bmp

Downloads

4

Readme

A library for jpeg to bmp, with a lovely and simple API. See https://womenzhai.cn/project for all the documentation.

前言

这是一个将 JPG 图像转换为 BMP 图像的 Node.js 模块。因此,该模块主要的功能就是读取 JPG 图像文件,解码文件中的二进制数据,并将其转换为 BMP 格式,最后将转换后的数据写入到新的 BMP 文件中

原理

将 JPG 图像转换为 BMP 图像之前,需要先将 JPG 图像解码成 RGB 格式。这是因为 JPG 格式使用的是基于离散余弦变换(DCT)的压缩算法,它将原始的 RGB 图像数据转换为一组 DCT 系数,并进行压缩存储。将 JPG 图像解码成 RGB 格式后,就可以得到完整的图像信息。在 BMP 图片中,颜色是 BGR 排列的,每行的存储顺序是从左到右,但是每行的颜色值又是从下到上存储的。所以进行了转换。BMP 文件格式是由文件头、位图信息头和像素数据三部分组成的。其中,文件头(File Header)包含了文件类型、文件大小、位图数据的偏移量等信息;位图信息头(Bitmap Info Header)则包含了图像的宽度、高度、颜色位数等信息;像素数据(Pixel Data)则包含了图像的实际像素值数据。

使用方法

    const jpg2bmp = require('jpg2bmp');
    
    var bmpBuffer = jpg2bm.convertToBuffer(jpgBuffer, {bitDepth: 32})

API接口

  1. 函数将接受一个 JPG 文件的缓冲区,并返回一个 BMP 文件的缓冲区, bitDepth为图片位深度
    static convertToBuffer: (jpgBuffer: Buffer,opts?: {
        bitDepth?: number ;
      }) => Buffer;
  1. 函数将接受一个 JPG 文件的路径,并返回一个 BMP 文件的缓冲区, bitDepth为图片位深度
    static convertToBufferFromFile: (jpgPath: string,opts?: {
        bitDepth?: number ;
      }) => Buffer;
  1. 函数将接受一个JPG 文件的路径和一个 BMP文件的路径, bitDepth为图片位深度
    static convertToFile: (jpgPath: string, bmpPath: string, opts?: {
        bitDepth?: number ;
    }) => void;

License

jpg2bmp is dual-licensed. You may use it under the MIT license or the GPLv3 license.