Example #1
0
func ParseIFD(br tiff.BReader, offset uint64, tsp tiff.TagSpace, ftsp tiff.FieldTypeSpace) (out tiff.IFD, err error) {
	if br == nil {
		return nil, errors.New("tiff: no BReader supplied")
	}
	if ftsp == nil {
		ftsp = tiff.DefaultFieldTypeSpace
	}
	if tsp == nil {
		tsp = tiff.DefaultTagSpace
	}
	ifd := &imageFileDirectory{
		fieldMap: make(map[uint16]tiff.Field, 1),
	}
	br.Seek(int64(offset), 0)
	if err = br.BRead(&ifd.numEntries); err != nil {
		err = fmt.Errorf("bigtiff: unable to read the number of entries for the IFD at offset %#08x: %v", offset, err)
		return
	}
	for i := uint64(0); i < ifd.numEntries; i++ {
		var f tiff.Field
		if f, err = ParseField(br, tsp, ftsp); err != nil {
			return
		}
		ifd.fields = append(ifd.fields, f)
		ifd.fieldMap[f.Tag().ID()] = f
	}
	if err = br.BRead(&ifd.nextOffset); err != nil {
		err = fmt.Errorf("bigtiff: unable to read the offset for the next ifd: %v", err)
		return
	}
	return ifd, nil
}
Example #2
0
func fiExposureProgram(f tiff.Field) string {
	prog := f.Type().Valuer()(f.Value().Bytes(), f.Value().Order()).Uint()
	if prog >= uint64(len(exposureProgramVals)) {
		return ""
	}
	return exposureProgramVals[prog]
}
Example #3
0
// fiRatAsFloat displays a rational as a float with 2 decimal points.
func fiRatAsFloat(f tiff.Field) string {
	return f.Type().Valuer()(f.Value().Bytes(), f.Value().Order()).Interface().(*big.Rat).FloatString(2)
}