mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-09 07:28:44 -07:00
Merge pull request #347 from vansante/master
Support more HEIF file types based on file magic signatures
This commit is contained in:
commit
dc6db012b2
3 changed files with 18 additions and 2 deletions
BIN
testdata/test3.heic
vendored
Normal file
BIN
testdata/test3.heic
vendored
Normal file
Binary file not shown.
|
|
@ -21,6 +21,7 @@ func TestDeterminateImageType(t *testing.T) {
|
||||||
// {"test.jp2", MAGICK},
|
// {"test.jp2", MAGICK},
|
||||||
{"test.heic", HEIF},
|
{"test.heic", HEIF},
|
||||||
{"test2.heic", HEIF},
|
{"test2.heic", HEIF},
|
||||||
|
{"test3.heic", HEIF},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
|
|
|
||||||
19
vips.go
19
vips.go
|
|
@ -708,12 +708,27 @@ func vipsImageType(buf []byte) ImageType {
|
||||||
// https://github.com/strukturag/libheif/issues/83#issuecomment-421427091
|
// https://github.com/strukturag/libheif/issues/83#issuecomment-421427091
|
||||||
if IsTypeSupported(HEIF) && buf[4] == 0x66 && buf[5] == 0x74 && buf[6] == 0x79 && buf[7] == 0x70 &&
|
if IsTypeSupported(HEIF) && buf[4] == 0x66 && buf[5] == 0x74 && buf[6] == 0x79 && buf[7] == 0x70 &&
|
||||||
buf[8] == 0x68 && buf[9] == 0x65 && buf[10] == 0x69 && buf[11] == 0x63 {
|
buf[8] == 0x68 && buf[9] == 0x65 && buf[10] == 0x69 && buf[11] == 0x63 {
|
||||||
// This is a HEIC file
|
// This is a HEIC file, ftypheic
|
||||||
return HEIF
|
return HEIF
|
||||||
}
|
}
|
||||||
if IsTypeSupported(HEIF) && buf[4] == 0x66 && buf[5] == 0x74 && buf[6] == 0x79 && buf[7] == 0x70 &&
|
if IsTypeSupported(HEIF) && buf[4] == 0x66 && buf[5] == 0x74 && buf[6] == 0x79 && buf[7] == 0x70 &&
|
||||||
buf[8] == 0x6d && buf[9] == 0x69 && buf[10] == 0x66 && buf[11] == 0x31 {
|
buf[8] == 0x6d && buf[9] == 0x69 && buf[10] == 0x66 && buf[11] == 0x31 {
|
||||||
// This is a HEIF file
|
// This is a HEIF file, ftypmif1
|
||||||
|
return HEIF
|
||||||
|
}
|
||||||
|
if IsTypeSupported(HEIF) && buf[4] == 0x66 && buf[5] == 0x74 && buf[6] == 0x79 && buf[7] == 0x70 &&
|
||||||
|
buf[8] == 0x6d && buf[9] == 0x73 && buf[10] == 0x66 && buf[11] == 0x31 {
|
||||||
|
// This is a HEIFS file, ftypmsf1
|
||||||
|
return HEIF
|
||||||
|
}
|
||||||
|
if IsTypeSupported(HEIF) && buf[4] == 0x66 && buf[5] == 0x74 && buf[6] == 0x79 && buf[7] == 0x70 &&
|
||||||
|
buf[8] == 0x68 && buf[9] == 0x65 && buf[10] == 0x69 && buf[11] == 0x73 {
|
||||||
|
// This is a HEIFS file, ftypheis
|
||||||
|
return HEIF
|
||||||
|
}
|
||||||
|
if IsTypeSupported(HEIF) && buf[4] == 0x66 && buf[5] == 0x74 && buf[6] == 0x79 && buf[7] == 0x70 &&
|
||||||
|
buf[8] == 0x68 && buf[9] == 0x65 && buf[10] == 0x76 && buf[11] == 0x63 {
|
||||||
|
// This is a HEIFS file, ftyphevc
|
||||||
return HEIF
|
return HEIF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue