When you pull EXIF data from an image with PHP, it has a Flash
value which is an integer.
For example, 16
which when converted to hex is 0x10
. This means the flash was switched off, and the flash didn't fire:
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, Red-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
Is there a way to enumerate this in PHP using bitwise so that a readable string can be returned.
For example, a value of 25
which is 0x19
would look perhaps something like this (and seems to work):
$fired = 0x01;
$auto = 0x18;
$flashValue = dechex(25); // 0x19
$parts = [];
if ($flashValue & $fired)
{
$parts[] = 'Fired';
}
if ($flashValue & $auto)
{
$parts[] = 'Auto';
}
$string = implode(', ', $parts); // "Fired, Auto"
This seems to work but examples such as the original example I can't seem to get working.