Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
jajbshjahavahh
GitHub Repository: jajbshjahavahh/Gojo-Satoru
Path: blob/master/node_modules/@jimp/tiff/src/index.js
2593 views
1
import UTIF from 'utif';
2
3
const MIME_TYPE = 'image/tiff';
4
5
export default () => ({
6
mime: { [MIME_TYPE]: ['tiff', 'tif'] },
7
8
constants: {
9
MIME_TIFF: MIME_TYPE
10
},
11
12
decoders: {
13
[MIME_TYPE]: data => {
14
const ifds = UTIF.decode(data);
15
const page = ifds[0];
16
UTIF.decodeImages(data, ifds);
17
const rgba = UTIF.toRGBA8(page);
18
19
return {
20
data: Buffer.from(rgba),
21
width: page.t256[0],
22
height: page.t257[0]
23
};
24
}
25
},
26
27
encoders: {
28
[MIME_TYPE]: image => {
29
const tiff = UTIF.encodeImage(
30
image.bitmap.data,
31
image.bitmap.width,
32
image.bitmap.height
33
);
34
35
return Buffer.from(tiff);
36
}
37
}
38
});
39
40