Skip to content

Commit

Permalink
added avif support & renamed heic.mjs -> heif.mjs
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeKovarik committed May 6, 2021
1 parent e03e5a5 commit d0ac78b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/bundles/full.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import '../file-readers/Base64Reader.mjs'

// File Parsers
import '../file-parsers/tiff.mjs'
import '../file-parsers/heic.mjs'
import '../file-parsers/heif.mjs'
import '../file-parsers/png.mjs'

// TIFF - Additional tags
Expand Down
2 changes: 1 addition & 1 deletion src/bundles/lite.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import '../file-readers/BlobReader.mjs'

// File Parser
import '../file-parsers/jpeg.mjs'
import '../file-parsers/heic.mjs'
import '../file-parsers/heif.mjs'

// TIFF Parser
import '../segment-parsers/tiff-exif.mjs'
Expand Down
17 changes: 12 additions & 5 deletions src/file-parsers/heic.mjs → src/file-parsers/heif.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ export class IsoBmffParser extends FileParserBase {

}

export class HeicFileParser extends IsoBmffParser {

static type = 'heic'
export class HeifFileParser extends IsoBmffParser {

// NOTE: most parsers check if bytes 4-8 are 'ftyp' and then if 8-12 is one of heic/heix/hevc/hevx/heim/heis/hevm/hevs/mif1/msf1
// but bytes 20-24 are actually always 'heic' for all of these formats
Expand All @@ -73,7 +71,7 @@ export class HeicFileParser extends IsoBmffParser {
compatibleBrands.push(file.getString(offset, 4))
offset += 4
}
return compatibleBrands.includes('heic')
return compatibleBrands.includes(this.type)
}

async parse() {
Expand Down Expand Up @@ -207,4 +205,13 @@ export class HeicFileParser extends IsoBmffParser {

}

fileParsers.set('heic', HeicFileParser)
export class HeicFileParser extends HeifFileParser {
static type = 'heic'
}

export class AvifFileParser extends HeifFileParser {
static type = 'avif'
}

fileParsers.set('heic', HeicFileParser)
fileParsers.set('avif', AvifFileParser)

0 comments on commit d0ac78b

Please sign in to comment.