douchun3680 2014-02-14 10:35
浏览 61
已采纳

exif_read_data vs exec(exiftool ...)

i have the following problem:

I work in maintenance in a new inherited project. In this project the developers work on metadata of image and video in this way:

function getRotationFromFile($realPath) {
    $retVal = Array();

    $cmd = variable_get("exiftool",null) . "\"$realPath\"" . " | grep -E 'Rotation|Camera Identifier'";
    exec($cmd, $output);

    foreach ($output as $row){
        $key = trim(strstr($row, ':', true));
        $value = trim(str_replace(": ", "", strstr($row, ': ')));
        $retVal[$key] = $value;
    }
    return $retVal;
}

As you can read, this function, call the exec(exiftool..) and retrieve some metadata. I know that in php exists exif_read_data, that done the same.

My questions are:

  1. What is the best solution?
  2. Who is the faster one?
  3. Who is the more "correct" one?
  4. Finally, i try to search but i don't find if exif_read_data use exiftool in source

Thank you in advance!

  • 写回答

3条回答 默认 最新

  • duanou2526 2016-09-26 22:33
    关注

    From what I can tell, exif_read_data will only read EXIF data, not any other sort of metadata, as well as being limited to Tiff and Jpg files. EXIF chunks only very rarely appear in video files. Additionally, the two tags you're looking for in that bit of code, Camera Identifier and Rotation, are not tags are part of the EXIF specification. Camera Identifier appears to be a Quicktime tag, while Rotation appears to be a Nikon and Canon makernotes tag.

    One thing that could be done is to tell Exiftool to show only the tags you want rather than piping it through grep. This can be done by adding -CameraIdentifier -Rotation to the command line. The quiet option -q might also be useful for this.

    You might also want to look into the Orientation tag, as that is the standard tag to hold the orientation for image files.

    @tsmgeek probably has the best solution, as they are correct about the startup overhead.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题