0

I'm using from PIL import Image, ExifTags to access exif data of images.

exif.get('ExposureTime') returns 0.008 but I would like it expressed as 1/125. I can see this value under the ExposureTime dict. But how do I access it?

Spatial Digger
  • 1,883
  • 1
  • 19
  • 37
  • 1
    post some code... perhaps how you can 'see it'? if it's just a dict it should be pretty easy to get it. – 2e0byo Jan 26 '22 at 16:17
  • 1
    Does [this](https://stackoverflow.com/questions/23344185/how-to-convert-a-decimal-number-into-fraction) help? – 0x263A Jan 26 '22 at 16:19
  • 0.008 are the **amount in seconds** that the exposure took, which gives 1/125 **fractions of a second**. Basically you want convert seconds in fractions of a second. – Fusseldieb Jan 26 '22 at 17:05
  • In Pycharm I see `ExposureTime` dict with a value of `0.008` yes the decimal of 1/125. Within the dict, labelled `real` is the value 1/125. For different images the value will be different. – Spatial Digger Jan 26 '22 at 18:35

1 Answers1

1

You need to get the reciprocal 1/x. So 1/0.008 = 125. Since the shutter speed is stored as a float you just need to format it as a string "1/"+str(1/0.008) will result in 1/125

Julia Meshcheryakova
  • 3,162
  • 3
  • 22
  • 42
W. P. Vern
  • 11
  • 1