Read EXIF and determine if the flash has fired
I have been reading some EXIF data with my PHP script. I want to determine for a certain image if the flash has been used. Here are the values returned by EXIF reader
0x0 = No Flash
0x1 = Fired
0x5 = Fired, Return not detected
0x7 = Fired, Return detected
0x8 = On, Did not fire
0x9 = On, Fired
0xd = On, Return not detected
0xf = On, Return detected
0x10 = Off, Did not fire
0x14 = Off, Did not fire, Return not detected
0x18 = Auto, Did not fire
0x19 = Auto, Fired
0x1d = Auto, Fired, Return not detected
0x1f = Auto, Fired, Return detected
0x20 = No flash function
0x30 = Off, No flash function
0x41 = Fired, Red-eye reduction
0x45 = Fired, Red-eye reduction, Return not detected
0x47 = Fired, Red-eye reduction, Return detected
0x49 = On, R开发者_开发知识库ed-eye reduction
0x4d = On, Red-eye reduction, Return not detected
0x4f = On, Red-eye reduction, Return detected
0x50 = Off, Red-eye reduction
0x58 = Auto, Did not fire, Red-eye reduction
0x59 = Auto, Fired, Red-eye reduction
0x5d = Auto, Fired, Red-eye reduction, Return not detected
0x5f = Auto, Fired, Red-eye reduction, Return detected
Which of them mean that the flash has been used?
Best regards, Mladjo
The flash property is actually a combination of the following flags:
0: FlashDidNotFire
1: FlashFired
2: StrobeReturnLightDetected
4: StrobeReturnLightNotDetected
8: CompulsoryFlashMode
16: AutoMode
32: NoFlashFunction
64: RedEyeReductionMode
To check if the flash has fired, bitwise AND the flash property with 1
:
$flashfired = ($exifflashproperty & 1) != 0;
I believe if you convert the Hex value to binary, the right most digit then indicates if the flash actually fired or not.
Therefore:
+-------------------------------------------------------+------+----------+-------+
| Status | Hex | Binary | Fired |
+-------------------------------------------------------+------+----------+-------+
| No Flash | 0x0 | 00000000 | No |
| Fired | 0x1 | 00000001 | Yes |
| "Fired, Return not detected" | 0x5 | 00000101 | Yes |
| "Fired, Return detected" | 0x7 | 00000111 | Yes |
| "On, Did not fire" | 0x8 | 00001000 | No |
| "On, Fired" | 0x9 | 00001001 | Yes |
| "On, Return not detected" | 0xd | 00001011 | Yes |
| "On, Return detected" | 0xf | 00001111 | Yes |
| "Off, Did not fire" | 0x10 | 00010000 | No |
| "Off, Did not fire, Return not detected" | 0x14 | 00010100 | No |
| "Auto, Did not fire" | 0x18 | 00011000 | No |
| "Auto, Fired" | 0x19 | 00011001 | Yes |
| "Auto, Fired, Return not detected" | 0x1d | 00011101 | Yes |
| "Auto, Fired, Return detected" | 0x1f | 00011111 | Yes |
| No flash function | 0x20 | 00100000 | No |
| "Off, No flash function" | 0x30 | 00110000 | No |
| "Fired, Red-eye reduction" | 0x41 | 01000001 | Yes |
| "Fired, Red-eye reduction, Return not detected" | 0x45 | 01000101 | Yes |
| "Fired, Red-eye reduction, Return detected" | 0x47 | 01000111 | Yes |
| "On, Red-eye reduction" | 0x49 | 01001001 | Yes |
| "On, Red-eye reduction, Return not detected" | 0x4d | 01001101 | Yes |
| "On, Red-eye reduction, Return detected" | 0x4f | 01001111 | Yes |
| "Off, Red-eye reduction" | 0x50 | 01010000 | No |
| "Auto, Did not fire, Red-eye reduction" | 0x58 | 01011000 | No |
| "Auto, Fired, Red-eye reduction" | 0x59 | 01011001 | Yes |
| "Auto, Fired, Red-eye reduction, Return not detected" | 0x5d | 01011101 | Yes |
| "Auto, Fired, Red-eye reduction, Return detected" | 0x5f | 01011111 | Yes |
+-------------------------------------------------------+------+----------+-------+
To simplify things, you can follow this: odd value means flash fired and even value (including zero) means flash did not fire.
You can get more information and meaning of each value at Tiff Tag Reference.
精彩评论