File tree Expand file tree Collapse file tree
services/search/pkg/content Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -63,10 +63,12 @@ func (t Tika) getPhoto(meta map[string][]string) *libregraph.Photo {
6363 }
6464
6565 if v , err := getFirstValue (meta , "exif:ExposureTime" ); err == nil {
66- if i , err := strconv .ParseFloat (v , 64 ); err == nil && i > 0 {
67- initPhoto ()
68- photo .SetExposureNumerator (1 )
69- photo .SetExposureDenominator (math .Round (1 / i ))
66+ if i , err := strconv .ParseFloat (v , 64 ); err == nil {
67+ if d := math .Round (1 / i ); ! math .IsNaN (d ) && ! math .IsInf (d , 0 ) && d > 0 {
68+ initPhoto ()
69+ photo .SetExposureNumerator (1 )
70+ photo .SetExposureDenominator (d )
71+ }
7072 }
7173 }
7274
Original file line number Diff line number Diff line change @@ -146,14 +146,16 @@ var _ = Describe("Tika", func() {
146146 })
147147
148148 It ("ignores zero exposure time" , func () {
149- fullResponse = `[{"exif:ExposureTime": "0.0"}]`
149+ fullResponse = `[{"exif:ExposureTime": "0.0", "exif:FNumber": "2.0" }]`
150150
151151 doc , err := tika .Extract (context .TODO (), & provider.ResourceInfo {
152152 Type : provider .ResourceType_RESOURCE_TYPE_FILE ,
153153 Size : 1 ,
154154 })
155155 Expect (err ).ToNot (HaveOccurred ())
156- Expect (doc .Photo ).To (BeNil ())
156+ Expect (doc .Photo ).ToNot (BeNil ())
157+ Expect (doc .Photo .FNumber ).To (Equal (libregraph .PtrFloat64 (2 )))
158+ Expect (doc .Photo .ExposureDenominator ).To (BeNil ())
157159 })
158160
159161 It ("removes stop words" , func () {
You can’t perform that action at this time.
0 commit comments