Skip to content

Instantly share code, notes, and snippets.

@dooman87
Created November 10, 2021 04:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dooman87/5166d6739fe6428a3bad00989302bf3c to your computer and use it in GitHub Desktop.
Save dooman87/5166d6739fe6428a3bad00989302bf3c to your computer and use it in GitHub Desktop.
var isIllustrationTests = []*testIsIllustration{
{"illustration-1.png", true},
{"illustration-2.png", true},
{"illustration-3.png", true},
{"logo-1.png", true},
{"logo-2.png", true},
{"banner-1.png", false},
{"screenshot-1.png", false},
{"photo-1.png", false},
{"photo-2.png", false},
{"photo-3.png", false},
{"product-1.png", false},
{"product-2.png", false},
}
func TestImageMagick_IsIllustration(t *testing.T) {
for _, tt := range isIllustrationTests {
imgFile := tt.file
f := fmt.Sprintf("%s/%s", "./test_files/is_illustration", imgFile)
orig, err := ioutil.ReadFile(f)
if err != nil {
t.Errorf("Can't read file %s: %+v", f, err)
}
image := &img.Image{
Id: imgFile,
Data: orig,
MimeType: "",
}
info, err := proc.LoadImageInfo(image)
if err != nil {
t.Errorf("could not load image info %s: %s", imgFile, err)
}
if err != nil {
t.Errorf("Unexpected error [%s]: %s", imgFile, err)
}
if info.Illustration != tt.isIllustration {
t.Errorf("Expected [%t] for [%s], but got [%t]", tt.isIllustration, imgFile, info.Illustration)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment