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条)

报告相同问题?

悬赏问题

  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退