@@ -89,6 +89,7 @@ func Test_OpenBytesFailures(t *testing.T) {
8989}
9090
9191func TestMetadata (t * testing.T ) {
92+ initializeImage ("testdata/pixel.jpg" , t )
9293 img , err := goexiv .Open ("testdata/pixel.jpg" )
9394 require .NoError (t , err )
9495
@@ -311,3 +312,33 @@ func Test_GetBytes(t *testing.T) {
311312 "Image size must not change after the same tag has been set" ,
312313 )
313314}
315+
316+ // Fills the image with metadata
317+ func initializeImage (path string , t * testing.T ) {
318+ img , err := goexiv .Open (path )
319+ require .NoError (t , err )
320+
321+ img .SetIptcString ("Iptc.Application2.Copyright" , "this is the copy, right?" )
322+ img .SetIptcString ("Iptc.Application2.CountryName" , "Lancre" )
323+ img .SetIptcString ("Iptc.Application2.DateCreated" , "20121013" )
324+ img .SetIptcString ("Iptc.Application2.TimeCreated" , "124932:0100" )
325+
326+ exifTags := map [string ]string {
327+ "Exif.Image.Make" : "FakeMake" ,
328+ "Exif.Image.Model" : "FakeModel" ,
329+ "Exif.Image.ResolutionUnit" : "2" ,
330+ "Exif.Image.XResolution" : "72/1" ,
331+ "Exif.Image.YCbCrPositioning" : "1" ,
332+ "Exif.Image.YResolution" : "72/1" ,
333+ "Exif.Photo.ColorSpace" : "65535" ,
334+ "Exif.Photo.ComponentsConfiguration" : "1 2 3 0" ,
335+ "Exif.Photo.DateTimeDigitized" : "2013:12:08 21:06:10" ,
336+ "Exif.Photo.ExifVersion" : "48 50 51 48" ,
337+ "Exif.Photo.FlashpixVersion" : "48 49 48 48" ,
338+ }
339+
340+ for k , v := range exifTags {
341+ err = img .SetExifString (k , v )
342+ require .NoError (t , err , k , v )
343+ }
344+ }
0 commit comments