-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathxbm.js
More file actions
25 lines (21 loc) · 719 Bytes
/
xbm.js
File metadata and controls
25 lines (21 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import {lazystream} from '../util.js';
export function readMediaAttributes(input) {
const stream = lazystream(input);
const firstLine = stream.takeLine().toString();
const secondLine = stream.takeLine().toString();
const result = {
width: 0,
height: 0,
size: stream.size(),
mime: 'image/x-xbitmap',
};
if (firstLine.match(/width/i)) {
result.width = parseInt(firstLine.split(' ').pop(), 10);
result.height = parseInt(secondLine.split(' ').pop(), 10);
} else {
result.width = parseInt(secondLine.split(' ').pop(), 10);
result.height = parseInt(firstLine.split(' ').pop(), 10);
}
stream.close();
return result;
}