File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -13,9 +13,14 @@ const brandMap = {
13
13
14
14
export const HEIF : IImage = {
15
15
validate ( input ) {
16
- const ftype = toUTF8String ( input , 4 , 8 )
17
- const brand = toUTF8String ( input , 8 , 12 )
18
- return 'ftyp' === ftype && brand in brandMap
16
+ const boxType = toUTF8String ( input , 4 , 8 )
17
+ if ( boxType !== 'ftyp' ) return false
18
+
19
+ const ftypBox = findBox ( input , 'ftyp' , 0 )
20
+ if ( ! ftypBox ) return false
21
+
22
+ const brand = toUTF8String ( input , ftypBox . offset + 8 , ftypBox . offset + 12 )
23
+ return brand in brandMap
19
24
} ,
20
25
21
26
calculate ( input ) {
Original file line number Diff line number Diff line change 1
1
import type { IImage } from './interface'
2
- import { readUInt32BE , findBox } from './utils'
2
+ import { readUInt32BE , findBox , toUTF8String } from './utils'
3
3
4
4
export const JP2 : IImage = {
5
5
validate ( input ) {
6
- if ( readUInt32BE ( input , 4 ) !== 0x6a502020 || readUInt32BE ( input , 0 ) < 1 ) return false
6
+ const boxType = toUTF8String ( input , 4 , 8 )
7
+ if ( boxType !== 'jP ' ) return false
8
+
7
9
const ftypBox = findBox ( input , 'ftyp' , 0 )
8
10
if ( ! ftypBox ) return false
9
- return readUInt32BE ( input , ftypBox . offset + 4 ) === 0x66747970
11
+
12
+ const brand = toUTF8String ( input , ftypBox . offset + 8 , ftypBox . offset + 12 )
13
+ return brand === 'jp2 '
10
14
} ,
11
15
12
16
calculate ( input ) {
You can’t perform that action at this time.
0 commit comments