• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nodeca / probe-image-size / 25260964598

02 May 2026 08:19PM UTC coverage: 99.438% (-0.3%) from 99.712%
25260964598

push

github

puzrin
Improve BMP handling

691 of 696 branches covered (99.28%)

17 of 20 new or added lines in 2 files covered. (85.0%)

1 existing line in 1 file now uncovered.

1061 of 1067 relevant lines covered (99.44%)

996.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.44
/lib/parse_sync/bmp.js
1
'use strict';
2

3
/* eslint-disable consistent-return */
4

5
var str2arr      = require('../common').str2arr;
3✔
6
var sliceEq      = require('../common').sliceEq;
3✔
7
var readInt16LE = require('../common').readInt16LE;
3✔
8
var readInt32LE = require('../common').readInt32LE;
3✔
9
var readUInt32LE = require('../common').readUInt32LE;
3✔
10

11
var SIG_BM = str2arr('BM');
3✔
12

13

14
module.exports = function (data) {
3✔
15
  if (data.length < 26) return;
204✔
16

17
  if (!sliceEq(data, 0, SIG_BM)) return;
156✔
18

19
  var h;
20
  var w;
21
  var headerSize = readUInt32LE(data, 14);
6✔
22

23
  if (headerSize === 12) {
6✔
24
    // BMP v2 header
25
    w = readInt16LE(data, 18);
3✔
26
    h = readInt16LE(data, 20);
3✔
27
  } else if (headerSize > 12) {
3!
28
    // BMP v3+ header
29
    w = readInt32LE(data, 18);
3✔
30
    h = readInt32LE(data, 22);
3✔
31
  } else {
32
    // BPM v1 and other garbage (10 bytes usually)
NEW
33
    return;
×
34
  }
35

36
  return {
6✔
37
    width:  w,
38
    // Height can be negative to indicate a top-down bitmap
39
    height: Math.abs(h),
40
    type: 'bmp',
41
    mime: 'image/bmp',
42
    wUnits: 'px',
43
    hUnits: 'px'
44
  };
45
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc