Skip to content

Commit

Permalink
bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
antonsergeyev committed Sep 13, 2020
1 parent 6ed2746 commit 497f6a5
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions exiv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func Test_OpenBytesFailures(t *testing.T) {
}

func TestMetadata(t *testing.T) {
initializeImage("testdata/pixel.jpg", t)
img, err := goexiv.Open("testdata/pixel.jpg")
require.NoError(t, err)

Expand Down Expand Up @@ -311,3 +312,33 @@ func Test_GetBytes(t *testing.T) {
"Image size must not change after the same tag has been set",
)
}

// Fills the image with metadata
func initializeImage(path string, t *testing.T) {
img, err := goexiv.Open(path)
require.NoError(t, err)

img.SetIptcString("Iptc.Application2.Copyright", "this is the copy, right?")
img.SetIptcString("Iptc.Application2.CountryName", "Lancre")
img.SetIptcString("Iptc.Application2.DateCreated", "20121013")
img.SetIptcString("Iptc.Application2.TimeCreated", "124932:0100")

exifTags := map[string]string{
"Exif.Image.Make": "FakeMake",
"Exif.Image.Model": "FakeModel",
"Exif.Image.ResolutionUnit": "2",
"Exif.Image.XResolution": "72/1",
"Exif.Image.YCbCrPositioning": "1",
"Exif.Image.YResolution": "72/1",
"Exif.Photo.ColorSpace": "65535",
"Exif.Photo.ComponentsConfiguration": "1 2 3 0",
"Exif.Photo.DateTimeDigitized": "2013:12:08 21:06:10",
"Exif.Photo.ExifVersion": "48 50 51 48",
"Exif.Photo.FlashpixVersion": "48 49 48 48",
}

for k, v := range exifTags {
err = img.SetExifString(k, v)
require.NoError(t, err, k, v)
}
}

0 comments on commit 497f6a5

Please sign in to comment.