国产欧美日韩第一页|日本一二三不卡视频|在线精品小视频,亚洲第一免费播放区,metcn人体亚洲一区,亚洲精品午夜视频

幫助中心 >  技術(shù)知識庫 >  網(wǎng)站相關(guān) >  網(wǎng)站運營(yíng) >  python用來(lái)獲得圖片exif信息的庫實(shí)例分析

python用來(lái)獲得圖片exif信息的庫實(shí)例分析

2017-01-02 07:59:33 7858

python用來(lái)獲得圖片exif信息的庫實(shí)例分析


這篇文章主要介紹了python用來(lái)?得圖片exif信息的庫,實(shí)例分析了exif-py庫文件的使用技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了python用來(lái)獲得圖片exif信息的庫用法。分享給大家供大家參考。具體分析如下:

exif-py是一個(gè)純python實(shí)現的獲取圖片元數據的python庫,官方下載地址: 

http://www.tjdsmy.cn/viewvc/exif-py/source/EXIF.py?revision=19&view=markup

下面的代碼演示的是調用方法。


代碼如下:

# library test/debug function (dump given files)

if __name__ == '__main__':

    import sys

    import getopt

    # parse command line options/arguments

    try:

        opts, args = getopt.getopt(sys.argv[1:], "hqsdt:v", ["help", "quick", "strict", "debug", "stop-tag="])

    except getopt.GetoptError:

        usage(2)

    if args == []:

        usage(2)

    detailed = True

    stop_tag = 'UNDEF'

    debug = False

    strict = False

    for o, a in opts:

        if o in ("-h", "--help"):

            usage(0)

        if o in ("-q", "--quick"):

            detailed = False

        if o in ("-t", "--stop-tag"):

            stop_tag = a

        if o in ("-s", "--strict"):

            strict = True

        if o in ("-d", "--debug"):

            debug = True

    # output info for each file

    for filename in args:

        try:

            file=open(filename, 'rb')

        except:

            print "'%s' is unreadable "%filename

            continue

        print filename + ':'

        # get the tags

        data = process_file(file, stop_tag=stop_tag, details=detailed, strict=strict, debug=debug)

        if not data:

            print 'No EXIF information found'

            continue

        x=data.keys()

        x.sort()

        for i in x:

            if i in ('JPEGThumbnail', 'TIFFThumbnail'):

                continue

            try:

                print '   %s (%s): %s' %

                      (i, FIELD_TYPES[data[i].field_type][2], data[i].printable)

            except:

                print 'error', i, '"', data[i], '"'

        if 'JPEGThumbnail' in data:

            print 'File has JPEG thumbnail'

        print


希望本文所述對大家的Python程序設計有所幫助。



提交成功!非常感謝您的反饋,我們會(huì )繼續努力做到更好!

這條文檔是否有幫助解決問(wèn)題?

非常抱歉未能幫助到您。為了給您提供更好的服務(wù),我們很需要您進(jìn)一步的反饋信息:

在文檔使用中是否遇到以下問(wèn)題:
-->