获取“日期"照片而不是“修改日期";使用PHP exif_read_data [英] Getting "Taken Date" of a photo instead of "Modified Date" with PHP exif_read_data

查看:144
本文介绍了获取“日期"照片而不是“修改日期";使用PHP exif_read_data的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用exif_read_data PHP函数从照片中检索创建日期(请参见下面的代码.)从未经修改的照片中检索的日期返回拍摄日期".那些已被修改的-日期已修改".有没有办法忽略修改日期"字段来获取照片的拍摄日期?

I'm retrieving the creation date from a photo with exif_read_data PHP function (see the code below.) The dates retrieved from photos that haven't been modified return "Date Taken". Those that have been modified - "Date Modified". Is there a way to get the date a photo was taken, ignoring the "Date Modified" field?

$exif_data = exif_read_data ($filename);
if (!empty($exif_data['DateTime'])) {
    $exif_date = $exif_data['DateTime'];
}

谢谢.

我认为$ exif_data ['DateTime']使用第一个可用的日期字段.由于未修改的图片的修改日期"和拍摄日期"具有相同的值,因此在我的情况下,总是检索修改日期".

I think $exif_data['DateTime'] uses the first available date field. Since unmodified images had the same value for "Date Modified" and "Date Taken" it was always retrieving "Date Modified" in my case.

推荐答案

好吧,我知道这个问题有点迟了,因为一年前发布了这个问题,但是我发布这个答案是因为我和我丈夫有相同的问题向我展示了如何获得答案的一两个窍门,所以我与大家分享. 编写一个php脚本以打印出exif_read_data数组,您会发现各种有趣的信息.此(下)使用print_r()在命令行上打印到标准输出.如果向下滚动,您将看到两个非常有趣的键: [DateTime] => 2011:06:21 17:50:57和[DateTimeOriginal] => 2011:06:04 08:56:22

Okay, I know this is a bit late as this question was posted a year ago, but I am posting this answer because I had the same question and my husband showed me a trick or two about how to get the answer, so I am sharing it. Write a php script to print out the exif_read_data array and you will find all sorts of interesting information. This (below) was printed on command line to stdout using print_r(). If you scroll down you will see two very interesting keys: [DateTime] => 2011:06:21 17:50:57 and [DateTimeOriginal] => 2011:06:04 08:56:22

我希望这些可以帮助您获得所需的东西.

I hope these will help you get what you need.


Array
(
    [FileName] => Pirate(F).JPG
    [FileDateTime] => 1405733742
    [FileSize] => 4017033
    [FileType] => 2
    [MimeType] => image/jpeg
    [SectionsFound] => ANY_TAG, IFD0, THUMBNAIL, COMMENT, EXIF
    [COMPUTED] => Array
        (
            [html] => width="2592" height="3888"
            [Height] => 3888
            [Width] => 2592
            [IsColor] => 1
            [ByteOrderMotorola] => 1
            [ApertureFNumber] => f/16.0
            [Thumbnail.FileType] => 2
            [Thumbnail.MimeType] => image/jpeg
        )

    [Make] => Canon
    [Model] => Canon EOS DIGITAL REBEL XS
    [Orientation] => 1
    [XResolution] => 4718592/65536
    [YResolution] => 4718592/65536
    [ResolutionUnit] => 2
    [Software] => QuickTime 7.6.9
    [DateTime] => 2011:06:21 17:50:57
    [HostComputer] => Mac OS X 10.5.8
    [YCbCrPositioning] => 1
    [Exif_IFD_Pointer] => 260
    [THUMBNAIL] => Array
        (
            [Compression] => 6
            [XResolution] => 4718592/65536
            [YResolution] => 4718592/65536
            [ResolutionUnit] => 2
            [JPEGInterchangeFormat] => 628
            [JPEGInterchangeFormatLength] => 4867
            [YCbCrPositioning] => 1
        )

    [COMMENT] => Array
        (
            [0] => AppleMark

        )

    [ExposureTime] => 1/200
    [FNumber] => 16/1
    [ExposureProgram] => 2
    [ISOSpeedRatings] => 400
    [ExifVersion] => 0220
    [DateTimeOriginal] => 2011:06:04 08:56:22
    [DateTimeDigitized] => 2011:06:04 08:56:22
    [ShutterSpeedValue] => 499712/65536
    [ApertureValue] => 524288/65536
    [ExposureBiasValue] => 0/1
    [MeteringMode] => 5
    [Flash] => 9
    [FocalLength] => 18/1
    [ColorSpace] => 1
)

这篇关于获取“日期"照片而不是“修改日期";使用PHP exif_read_data的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆