@ -22,6 +22,7 @@ func TestDeterminateImageType(t *testing.T) {
{ "test.heic" , HEIF } ,
{ "test.heic" , HEIF } ,
{ "test2.heic" , HEIF } ,
{ "test2.heic" , HEIF } ,
{ "test3.heic" , HEIF } ,
{ "test3.heic" , HEIF } ,
{ "test.avif" , AVIF } ,
}
}
for _ , file := range files {
for _ , file := range files {
@ -51,12 +52,16 @@ func TestDeterminateImageTypeName(t *testing.T) {
{ "test.svg" , "svg" } ,
{ "test.svg" , "svg" } ,
// {"test.jp2", "magick"},
// {"test.jp2", "magick"},
{ "test.heic" , "heif" } ,
{ "test.heic" , "heif" } ,
{ "test.avif" , "avif" } ,
}
}
for _ , file := range files {
for _ , file := range files {
if file . expected == "heif" && VipsMajorVersion <= 8 && VipsMinorVersion < 8 {
if file . expected == "heif" && VipsMajorVersion <= 8 && VipsMinorVersion < 8 {
continue
continue
}
}
if file . expected == "avif" && VipsMajorVersion <= 8 && VipsMinorVersion < 9 {
continue
}
img , _ := os . Open ( path . Join ( "testdata" , file . name ) )
img , _ := os . Open ( path . Join ( "testdata" , file . name ) )
buf , _ := ioutil . ReadAll ( img )
buf , _ := ioutil . ReadAll ( img )
@ -73,13 +78,16 @@ func TestIsTypeSupported(t *testing.T) {
types := [ ] struct {
types := [ ] struct {
name ImageType
name ImageType
} {
} {
{ JPEG } , { PNG } , { WEBP } , { GIF } , { PDF } , { HEIF } ,
{ JPEG } , { PNG } , { WEBP } , { GIF } , { PDF } , { HEIF } , { AVIF } ,
}
}
for _ , n := range types {
for _ , n := range types {
if n . name == HEIF && VipsMajorVersion <= 8 && VipsMinorVersion < 8 {
if n . name == HEIF && VipsMajorVersion <= 8 && VipsMinorVersion < 8 {
continue
continue
}
}
if n . name == AVIF && VipsMajorVersion <= 8 && VipsMinorVersion < 9 {
continue
}
if IsTypeSupported ( n . name ) == false {
if IsTypeSupported ( n . name ) == false {
t . Fatalf ( "Image type %s is not valid" , ImageTypes [ n . name ] )
t . Fatalf ( "Image type %s is not valid" , ImageTypes [ n . name ] )
}
}
@ -97,12 +105,16 @@ func TestIsTypeNameSupported(t *testing.T) {
{ "gif" , true } ,
{ "gif" , true } ,
{ "pdf" , true } ,
{ "pdf" , true } ,
{ "heif" , true } ,
{ "heif" , true } ,
{ "avif" , true } ,
}
}
for _ , n := range types {
for _ , n := range types {
if n . name == "heif" && VipsMajorVersion <= 8 && VipsMinorVersion < 8 {
if n . name == "heif" && VipsMajorVersion <= 8 && VipsMinorVersion < 8 {
continue
continue
}
}
if n . name == "avif" && VipsMajorVersion <= 8 && VipsMinorVersion < 9 {
continue
}
if IsTypeNameSupported ( n . name ) != n . expected {
if IsTypeNameSupported ( n . name ) != n . expected {
t . Fatalf ( "Image type %s is not valid" , n . name )
t . Fatalf ( "Image type %s is not valid" , n . name )
}
}
@ -121,6 +133,9 @@ func TestIsTypeSupportedSave(t *testing.T) {
if VipsVersion >= "8.8.0" {
if VipsVersion >= "8.8.0" {
types = append ( types , struct { name ImageType } { HEIF } )
types = append ( types , struct { name ImageType } { HEIF } )
}
}
if VipsVersion >= "8.9.0" {
types = append ( types , struct { name ImageType } { AVIF } )
}
for _ , n := range types {
for _ , n := range types {
if IsTypeSupportedSave ( n . name ) == false {
if IsTypeSupportedSave ( n . name ) == false {
@ -141,6 +156,7 @@ func TestIsTypeNameSupportedSave(t *testing.T) {
{ "pdf" , false } ,
{ "pdf" , false } ,
{ "tiff" , VipsVersion >= "8.5.0" } ,
{ "tiff" , VipsVersion >= "8.5.0" } ,
{ "heif" , VipsVersion >= "8.8.0" } ,
{ "heif" , VipsVersion >= "8.8.0" } ,
{ "avif" , VipsVersion >= "8.9.0" } ,
}
}
for _ , n := range types {
for _ , n := range types {