關於部落格
雨--是天空的眼淚 風--是蝴蝶的痴醉 雲--是水珠的嫵媚 光--是溫暖的慰藉 夜--是孤單的滋味 星--是墜跌的心碎 蹲下,是為了躍起。 後退,是為了向前跳得更遠。
  • 171475

    累積人氣

  • 4

    今日人氣

    0

    訂閱人氣

PHP 取得圖片資訊



要如何透過PHP去取得圖片的資訊呢?
其實很簡單~
因為PHP就有提供一個函式 exif_read_data


在使用此函式之前
有一些環境要先設定
在php.ini裡
將 extension=php_exif.dll 的註解拿掉
然後 extension=php_exif.dll 要放在 extension=php_mbstring.dll 的後面
存檔完後, 再重啟apache


再來就可以直接使用囉~

以底下圖片為例
http://leafmemory.acsite.org/pic/DSCN3922.JPG

<?php
        $exif = exif_read_data('DSCN3922.JPG', 0, true);
        print_r($exif);
?>


輸出結果為以下:
可以看到很詳細的圖片資訊

Array
(
    [FILE] => Array
        (
            [FileName] => DSCN3922.JPG
            [FileDateTime] => 1329033636
            [FileSize] => 691952
            [FileType] => 2
            [MimeType] => image/jpeg
            [SectionsFound] => ANY_TAG, IFD0, THUMBNAIL, EXIF
        )

    [COMPUTED] => Array
        (
            [html] => width="1944" height="2592"
            [Height] => 2592
            [Width] => 1944
            [IsColor] => 1
            [ByteOrderMotorola] => 0
            [ApertureFNumber] => f/2.6
            [Thumbnail.FileType] => 2
            [Thumbnail.MimeType] => image/jpeg
        )

    [IFD0] => Array
        (
            [Make] => Sony Ericsson
            [Model] => WT19i
            [XResolution] => 72/1
            [YResolution] => 72/1
            [ResolutionUnit] => 2
            [Software] => 4.0.2.A.0.58_2d_f100
            [DateTime] => 2012:02:11 14:57:57
            [YCbCrPositioning] => 1
            [Exif_IFD_Pointer] => 280
            [CustomRendered] => 0
            [ExposureMode] => 0
            [WhiteBalance] => 0
            [DigitalZoomRatio] => 100/100
            [SceneCaptureType] => 0
            [SubjectDistanceRange] => 0
        )

    [THUMBNAIL] => Array
        (
            [Compression] => 6
            [Orientation] => 6
            [XResolution] => 72/1
            [YResolution] => 72/1
            [ResolutionUnit] => 2
            [JPEGInterchangeFormat] => 676
            [JPEGInterchangeFormatLength] => 7166
        )

    [EXIF] => Array
        (
            [ExposureTime] => 10/400
            [FNumber] => 26/10
            [ISOSpeedRatings] => 800
            [ExifVersion] => 0220
            [DateTimeOriginal] => 2012:02:11 14:57:57
            [DateTimeDigitized] => 2012:02:11 14:57:57
            [ComponentsConfiguration] => 
            [ShutterSpeedValue] => 532/100
            [ExposureBiasValue] => 0/3
            [MeteringMode] => 2
            [LightSource] => 0
            [Flash] => 16
            [FocalLength] => 350/100
            [FlashPixVersion] => 0100
            [ColorSpace] => 1
            [ExifImageWidth] => 1944
            [ExifImageLength] => 2592
        )

)



文:葉小誠

相簿設定
標籤設定
相簿狀態