diff --git a/pkg/ifd/entry.go b/pkg/ifd/entry.go index 130cd6e..5aefa98 100644 --- a/pkg/ifd/entry.go +++ b/pkg/ifd/entry.go @@ -10,6 +10,10 @@ package metadata /*****************************************************************************************************************/ +import "encoding/binary" + +/*****************************************************************************************************************/ + // An IFDEntry is a single entry in an Image File Directory. // A value of type DataTypeRational is composed of two 32-bit values, // thus data contains two uints (numerator and denominator) for a single number. @@ -20,3 +24,23 @@ type IFDEntry struct { } /*****************************************************************************************************************/ + +func (e IFDEntry) PutData(p []byte) { + enc := binary.LittleEndian + + for _, d := range e.Data { + switch e.DataType { + case DataTypeByte, DataTypeASCII: + p[0] = byte(d) + p = p[1:] + case DataTypeShort: + enc.PutUint16(p, uint16(d)) + p = p[2:] + case DataTypeLong, DataTypeRational: + enc.PutUint32(p, uint32(d)) + p = p[4:] + } + } +} + +/*****************************************************************************************************************/