欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python讀取圖片EXIF信息類庫介紹和使用實例

 更新時間:2014年07月10日 11:54:46   投稿:junjie  
這篇文章主要介紹了Python讀取圖片EXIF信息類庫介紹和使用實例,例如Python Imaging Library、EXIF.py等,需要的朋友可以參考下

首先要介紹的是 Python Imaging Library,使用方法如下:

復(fù)制代碼 代碼如下:

from PIL import Image
from PIL.ExifTags import TAGS

def get_exif_data(fname):
    """Get embedded EXIF data from image file."""
    ret = {}
    try:
        img = Image.open(fname)
        if hasattr( img, '_getexif' ):
            exifinfo = img._getexif()
            if exifinfo != None:
                for tag, value in exifinfo.items():
                    decoded = TAGS.get(tag, tag)
                    ret[decoded] = value
    except IOError:
        print 'IOERROR ' + fname
    return ret

if __name__ == '__main__':
    fileName = 'C:/Users/Leyond/Desktop/IMG_20121122_153514.jpg'
    exif = get_exif_data(fileName)
    print exif


返回的清單如下:

復(fù)制代碼 代碼如下:

ExifVersion
ComponentsConfiguration
ExifImageWidth
DateTimeOriginal
DateTimeDigitized
ExifInteroperabilityOffset
FlashPixVersion
MeteringMode
LightSource
Flash
FocalLength
41986
ImageDescription
Make
Model
Orientation
YCbCrPositioning
41988
XResolution
YResolution
59932
ExposureTime
ExposureProgram
ColorSpace
41990
ISOSpeedRatings
ResolutionUnit
41987
FNumber
Software
DateTime
ExifImageHeight
ExifOffset

其中59932,是一大串十六進制的字符,不知為啥。除了PIL之外,還有許多類庫可供使用:

Media Metadata for Python

EXIF.py

Python Exif Parser

A Blogger's Exif Parser

pyexiv2


接著看EXIF.PY,使用方法非常簡單:exif.py IMG_20121122_153514.jpg

復(fù)制代碼 代碼如下:

EXIF ColorSpace (Short): sRGB
EXIF ComponentsConfiguration (Undefined): YCbCr
EXIF DateTimeDigitized (ASCII): 2012:11:22 15:35:14
EXIF DateTimeOriginal (ASCII): 2012:11:22 15:35:14
EXIF DigitalZoomRatio (Ratio): 1
EXIF ExifImageLength (Long): 2560
EXIF ExifImageWidth (Long): 1920
EXIF ExifVersion (Undefined): 0220
EXIF ExposureBiasValue (Signed Ratio): 0
EXIF ExposureMode (Short): Auto Exposure
EXIF ExposureProgram (Short): Portrait Mode
EXIF ExposureTime (Ratio): 1/256
EXIF FNumber (Ratio): 14/5
EXIF Flash (Short): Flash did not fire
EXIF FlashPixVersion (Undefined): 0100
EXIF FocalLength (Ratio): 35
EXIF ISOSpeedRatings (Short): 56
EXIF InteroperabilityOffset (Long): 4810
EXIF LightSource (Short): other light source
EXIF MeteringMode (Short): CenterWeightedAverage
EXIF Padding (Undefined): []
EXIF SceneCaptureType (Short): Portrait
EXIF WhiteBalance (Short): Auto
Image DateTime (ASCII): 2012:11:24 09:44:50
Image ExifOffset (Long): 2396
Image ImageDescription (ASCII):
Image Make (ASCII):
Image Model (ASCII):
Image Orientation (Short): Horizontal (normal)
Image Padding (Undefined): []
Image ResolutionUnit (Short): Pixels/Inch
Image Software (ASCII): Microsoft Windows Photo Viewer 6.1.7600.16385
Image XResolution (Ratio): 72
Image YCbCrPositioning (Short): Co-sited
Image YResolution (Ratio): 72
Thumbnail Compression (Short): JPEG (old-style)
Thumbnail JPEGInterchangeFormat (Long): 4970
Thumbnail JPEGInterchangeFormatLength (Long): 3883
Thumbnail Orientation (Short): Horizontal (normal)
Thumbnail ResolutionUnit (Short): Pixels/Inch
Thumbnail XResolution (Ratio): 72
Thumbnail YCbCrPositioning (Short): Co-sited
Thumbnail YResolution (Ratio): 72

至于Python Exif Parser,好像沒更新很久了,使用方法也很類似:

復(fù)制代碼 代碼如下:

import exif
photo_path = "somePath\to\a\photo.jpg"
data = exif.parse(photo_path)

其他類庫請自行研究。

相關(guān)文章

  • python使用redis實現(xiàn)消息隊列(異步)的實現(xiàn)完整例程

    python使用redis實現(xiàn)消息隊列(異步)的實現(xiàn)完整例程

    本文主要介紹了python使用redis實現(xiàn)消息隊列(異步)的實現(xiàn)完整例程,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-01-01
  • python實現(xiàn)連連看游戲

    python實現(xiàn)連連看游戲

    這篇文章主要為大家詳細介紹了python實現(xiàn)連連看游戲,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-02-02
  • python可視化大屏庫big_screen示例詳解

    python可視化大屏庫big_screen示例詳解

    提到數(shù)據(jù)可視化,我們會想到 Plotly、Matplotlib、Pyecharts等可視化庫,或者一些商用軟件Tableau、FineBI等等。如果你希望操作更簡單、展現(xiàn)效果更強大,那么這款工具 big_screen 更適合
    2021-11-11
  • python中的數(shù)據(jù)結(jié)構(gòu)比較

    python中的數(shù)據(jù)結(jié)構(gòu)比較

    這篇文章主要介紹了python中的數(shù)據(jù)結(jié)構(gòu)比較,本文給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下
    2019-05-05
  • python獲取本周、上周、本月、上月及本季的時間代碼實例

    python獲取本周、上周、本月、上月及本季的時間代碼實例

    這篇文章主要給大家介紹了關(guān)于python獲取本周、上周、本月、上月及本季的時間的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-09-09
  • python中的垃圾回收(GC)機制

    python中的垃圾回收(GC)機制

    這篇文章主要介紹了python中的GC機制,幫助大家更好的理解和使用python,感興趣的朋友可以了解下
    2020-09-09
  • python版微信跳一跳游戲輔助

    python版微信跳一跳游戲輔助

    這篇文章主要為大家詳細介紹了python版微信跳一跳游戲輔助,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-01-01
  • Python的Django框架使用入門指引

    Python的Django框架使用入門指引

    這篇文章主要介紹了Python的Django框架使用入門指引,本文來自于IBM官方網(wǎng)站技術(shù)文檔,需要的朋友可以參考下
    2015-04-04
  • python添加列表元素append(),extend()及?insert()

    python添加列表元素append(),extend()及?insert()

    這篇文章主要介紹了python添加列表元素append(),extend()及?insert(),列表是儲存元素的數(shù)據(jù)類型,既然能存儲元素,那么就類似數(shù)據(jù)庫一樣,增刪改查的一些功能就不能少了。下面我們就來先看看添加列表元素方法有哪些,需要的朋友可以參考一下
    2022-03-03
  • Python實現(xiàn)中文數(shù)字轉(zhuǎn)換為阿拉伯?dāng)?shù)字的方法示例

    Python實現(xiàn)中文數(shù)字轉(zhuǎn)換為阿拉伯?dāng)?shù)字的方法示例

    這篇文章主要介紹了Python實現(xiàn)中文數(shù)字轉(zhuǎn)換為阿拉伯?dāng)?shù)字的方法,涉及Python字符串遍歷、轉(zhuǎn)換相關(guān)操作技巧,需要的朋友可以參考下
    2017-05-05

最新評論