使用按位来枚举EXIF闪存可读字符串

时间:2017-06-16 02:32:39

标签: php bit-manipulation exif

使用PHP从图像中提取EXIF数据时,它的值为Flash整数。

例如,16转换为十六进制时为0x10。这意味着闪光灯已关闭,闪光灯没有闪光:

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

有没有办法在PHP中使用按位枚举这个,以便可以返回一个可读的字符串。

例如,25的值0x19可能看起来像这样(并且似乎有效):

$fired = 0x01;
$auto = 0x18;

$flashValue = dechex(25); // 0x19

$parts = [];
if ($flashValue & $fired)
{
    $parts[] = 'Fired';
}
if ($flashValue & $auto)
{
    $parts[] = 'Auto';
}

$string = implode(', ', $parts); // "Fired, Auto"

这似乎有效,但原始示例中的示例似乎无法正常工作。

1 个答案:

答案 0 :(得分:1)

var x = girlsXml.find('dog:contains("'+i+'")');

请勿使用UPDATE YourTable SET RollNumber = RollNumber + 1; 。它返回一个字符串;您尝试使用的按位运算符对数字进行操作。 ($flashValue = dechex(25); // 0x19 是一个非常好的数字 - 你没有用十六进制编写的事实并不重要。)

你必须处理的一个复杂因素是“auto”是一个奇怪的标志组合:0x08是“关闭”,0x10是“开启”,并且两者组合(0x10 + 0x08) = 0x18)给你“自动”。您需要仔细处理这些问题。