當前位置: 首頁>>代碼示例>>Python>>正文


Python TAGS.get方法代碼示例

本文整理匯總了Python中PIL.ExifTags.TAGS.get方法的典型用法代碼示例。如果您正苦於以下問題:Python TAGS.get方法的具體用法?Python TAGS.get怎麽用?Python TAGS.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PIL.ExifTags.TAGS的用法示例。


在下文中一共展示了TAGS.get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testForExif

# 需要導入模塊: from PIL.ExifTags import TAGS [as 別名]
# 或者: from PIL.ExifTags.TAGS import get [as 別名]
def testForExif(imgFileName):
    try:
        exifData = {}
        imgFile = Image.open(imgFileName)
        info = imgFile._getexif()
        if info:
            for (tag, value) in info.items():
                decoded = TAGS.get(tag, tag)
                exifData[decoded] = value
            exifGPS = exifData['GPSInfo']
            if exifData:
                print '[*] ' + imgFileName + ' contains GPS MetaData'
    except:
        pass

#主函數 
開發者ID:sunshinelyz,項目名稱:python-hacker,代碼行數:18,代碼來源:meta_image.py

示例2: getExif

# 需要導入模塊: from PIL.ExifTags import TAGS [as 別名]
# 或者: from PIL.ExifTags.TAGS import get [as 別名]
def getExif(file_path):
    image = Image.open(file_path)

    exif = image._getexif()

    if exif is None:
        return

    exif_data = {}
    for tag_id, value in exif.items():
        tag = TAGS.get(tag_id, tag_id)

        # GPS情報は個別に扱う.
        if tag == "GPSInfo":
            gps_data = {}
            for t in value:
                gps_tag = GPSTAGS.get(t, t)
                gps_data[gps_tag] = value[t]

            exif_data[tag] = gps_data
        else:
            exif_data[tag] = value

    return exif_data 
開發者ID:tody411,項目名稱:PyIntroduction,代碼行數:26,代碼來源:pil_exif.py

示例3: writeMetaData

# 需要導入模塊: from PIL.ExifTags import TAGS [as 別名]
# 或者: from PIL.ExifTags.TAGS import get [as 別名]
def writeMetaData(imgname, tag, replace):
	try:
		metaData = {}
		imgFile = Image.open(imgname)
		imgData = imgFile.getdata()
		print "Getting meta data..."
		info = imgFile._getexif()
		if info:
			print "found meta data!"
			i = 0
			for (tag, value) in info.items():
				i = i + 1
				tagname = TAGS.get(tag, tag)
				#if tagname == tagToReplace:
					#info.items()[i][1] = replace

			print "Saving Change"
			outImg = Image.frombuffer("RGBX",len(imgData)+len(info),imgData+info)
			outImg.save(img)
		
	except:
		print "Failed" 
開發者ID:DrapsTV,項目名稱:DrapsTV_Materials,代碼行數:24,代碼來源:testWrite.py

示例4: getexptime

# 需要導入模塊: from PIL.ExifTags import TAGS [as 別名]
# 或者: from PIL.ExifTags.TAGS import get [as 別名]
def getexptime(filename):
    im = Image.open(filename)
    try:
        exif = im._getexif()
    except AttributeError:
        return 1.0

    exif_table = {}
    for tag_id, value in exif.items():
        tag = TAGS.get(tag_id, tag_id)
        exif_table[tag] = value

    expo_str = 'ExposureTime'
    expo_time = 1.0
    if expo_str in exif_table:
        expo_tubple = exif_table[expo_str]
        expo_time = expo_tuple[0] / expo_tuble[1]

    return expo_time 
開發者ID:tatsy,項目名稱:hydra,代碼行數:21,代碼來源:utils.py

示例5: resize_image

# 需要導入模塊: from PIL.ExifTags import TAGS [as 別名]
# 或者: from PIL.ExifTags.TAGS import get [as 別名]
def resize_image(image):
    img = Image.open(image)
    exif = img._getexif()
    if exif is not None:
        for tag, value in exif.items():
            decoded = TAGS.get(tag, tag)
            if decoded == 'Orientation':
                if value == 3:
                    img = img.rotate(180)
                if value == 6:
                    img = img.rotate(270)
                if value == 8:
                    img = img.rotate(90)
    img.thumbnail((1024, 768), Image.ANTIALIAS)
    try:
        img.save(resized_dir + '/' + image, 'JPEG', quality=100)
    except IOError as e:
        print("Unable to save resized image")
    img.thumbnail((192, 192), Image.ANTIALIAS)
    try:
        img.save(thumb_dir + '/' + image, 'JPEG')
    except IOError as e:
        print("Unable to save thumbnail") 
開發者ID:aws-samples,項目名稱:ecs-refarch-batch-processing,代碼行數:25,代碼來源:GetAndResizeImages.py

示例6: printExif

# 需要導入模塊: from PIL.ExifTags import TAGS [as 別名]
# 或者: from PIL.ExifTags.TAGS import get [as 別名]
def printExif(image):
    exifAttrs = set(["Model", "Make", "ExifImageWidth", "ExifImageHeight", "FocalLength"])
    exif = {}
    info = image._getexif()
    if info:
        for attr, value in info.items():
            decodedAttr = TAGS.get(attr, attr)
            if decodedAttr in exifAttrs: exif[decodedAttr] = value
    if 'FocalLength' in exif: exif['FocalLength'] = float(exif['FocalLength'][0])/float(exif['FocalLength'][1])

    outputString = ""
    if ('Make' in exif):
        outputString += exif['Make']
    outputString += ","

    if ('Model' in exif):
        outputString += exif['Model']
    outputString += ","

    if ('FocalLength' in exif):
        outputString += str(exif['FocalLength'])
    outputString += ","

    outputString += str(exif['ExifImageWidth']) + "," + str(exif['ExifImageHeight'])

    print(outputString) 
開發者ID:ApoorvaJ,項目名稱:BlenderSFM,代碼行數:28,代碼來源:pilbin.py

示例7: exif

# 需要導入模塊: from PIL.ExifTags import TAGS [as 別名]
# 或者: from PIL.ExifTags.TAGS import get [as 別名]
def exif(img):
    """Return EXIF metatdata from image"""
    exif_data = {}
    try:    
        i = Image.open(img)
        tags = i._getexif()
        for tag, value in tags.items():
            decoded = TAGS.get(tag, tag)
            exif_data[decoded] = value
    except:
        pass
    return exif_data 
開發者ID:PacktPublishing,項目名稱:Learning-Geospatial-Analysis-with-Python-Third-Edition,代碼行數:14,代碼來源:B13346_08_09-geolocate.py

示例8: exif1meta

# 需要導入模塊: from PIL.ExifTags import TAGS [as 別名]
# 或者: from PIL.ExifTags.TAGS import get [as 別名]
def exif1meta(image_path):

    ret = {}
    image = Image.open(image_path)
    if hasattr(image, '_getexif'):
        exifinfo = image._getexif()
        if exifinfo is not None:
            for tag, value in exifinfo.items():
                decoded = TAGS.get(tag, tag)
                ret[decoded] = value
    gps(ret)
    return ret 
開發者ID:VainlyStrain,項目名稱:Vaile,代碼行數:14,代碼來源:imgext.py

示例9: exif3meta

# 需要導入模塊: from PIL.ExifTags import TAGS [as 別名]
# 或者: from PIL.ExifTags.TAGS import get [as 別名]
def exif3meta(image_path):

    print(GR+'\n [*] Reading METADATA info...')
    for tag, value in Image.open(image_path)._getexif().iteritems():
        print(O+' [+] '+str(TAGS.get(tag))+' : '+C+str(value)) 
開發者ID:VainlyStrain,項目名稱:Vaile,代碼行數:7,代碼來源:imgext.py

示例10: get_exif

# 需要導入模塊: from PIL.ExifTags import TAGS [as 別名]
# 或者: from PIL.ExifTags.TAGS import get [as 別名]
def get_exif(self):
        """
        Get EXIF tags for JPEG images. Fails for non-JPEG images.

        :returns: EXIF tags.
        :rtype: dict(str -> str)

        :raise ValueError: Not a JPEG image.
        """

        # Check that it's really an image.
        if self.mime_subtype != "jpeg":
            raise ValueError("Not a JPEG image")

        # Lazy import.
        global PIL_TAGS
        if PIL_TAGS is None:
            from PIL.ExifTags import TAGS as PIL_TAGS

        # Load in PIL.
        img = self.to_pil()

        # Extract the EXIF tags.
        exif = {}
        try:
            info = img.tag.tags
        except AttributeError:
            info = img._getexif()
        if info:
            for tag, value in info.items():
                decoded = PIL_TAGS.get(tag, tag)
                exif[decoded] = value

        # Return the EXIF tags.
        return exif


    #-------------------------------------------------------------------------- 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:40,代碼來源:image.py

示例11: discovered

# 需要導入模塊: from PIL.ExifTags import TAGS [as 別名]
# 或者: from PIL.ExifTags.TAGS import get [as 別名]
def discovered(self):
        if self.mime_subtype == "jpeg":
            exif = self.get_exif()
            if "GPSInfo" in exif:
                try:
                    info = exif["GPSInfo"]
                    t_lat_d, t_lat_m, t_lat_s = info[2]   # GPSLatitude
                    t_lon_d, t_lon_m, t_lon_s = info[4]   # GPSLongitude
                    lat_d = float(t_lat_d[0]) / float(t_lat_d[1])
                    lat_m = float(t_lat_m[0]) / float(t_lat_m[1])
                    lat_s = float(t_lat_s[0]) / float(t_lat_s[1])
                    lon_d = float(t_lon_d[0]) / float(t_lon_d[1])
                    lon_m = float(t_lon_m[0]) / float(t_lon_m[1])
                    lon_s = float(t_lon_s[0]) / float(t_lon_s[1])
                    lat = lat_d + (lat_m / 60.0) + (lat_s / 3600)
                    lon = lon_d + (lon_m / 60.0) + (lon_s / 3600)
                    lat_ref = info.get(1, "N")            # GPSLatitudeRef
                    lon_ref = info.get(3, "E")            # GPSLongitudeRef
                    lat_ref = str(lat_ref).strip()[0].upper()
                    lon_ref = str(lon_ref).strip()[0].upper()
                    if lat_ref == "S":
                        lat = -lat
                    if lon_ref == "W":
                        lon = -lon
                    geoloc = Geolocation(
                        latitude  = lat,
                        longitude = lon,
                    )
                    geoloc.add_link(self)
                    return [geoloc]
                except Exception, e:
                    warn(str(e), RuntimeWarning) 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:34,代碼來源:image.py

示例12: get_exif

# 需要導入模塊: from PIL.ExifTags import TAGS [as 別名]
# 或者: from PIL.ExifTags.TAGS import get [as 別名]
def get_exif(file,field):
    img = Image.open(file)
    exif = img._getexif()

    exif_data = []
    for id, value in exif.items():
        if TAGS.get(id) == field:
            tag = TAGS.get(id, id),value
            exif_data.extend(tag)

    return exif_data 
開發者ID:karaage0703,項目名稱:python-image-processing,代碼行數:13,代碼來源:photo_exif_date_print.py

示例13: get_exif_of_image

# 需要導入模塊: from PIL.ExifTags import TAGS [as 別名]
# 或者: from PIL.ExifTags.TAGS import get [as 別名]
def get_exif_of_image(file):
    im = Image.open(file)

    try:
        exif = im._getexif()
    except AttributeError:
        return {}

    exif_table = {}
    for tag_id, value in exif.items():
        tag = TAGS.get(tag_id, tag_id)
        exif_table[tag] = value

    return exif_table 
開發者ID:karaage0703,項目名稱:python-image-processing,代碼行數:16,代碼來源:photo_exif_date_print.py

示例14: get_date_of_image

# 需要導入模塊: from PIL.ExifTags import TAGS [as 別名]
# 或者: from PIL.ExifTags.TAGS import get [as 別名]
def get_date_of_image(file):
    exif_table = get_exif_of_image(file)
    return exif_table.get("DateTimeOriginal") 
開發者ID:karaage0703,項目名稱:python-image-processing,代碼行數:5,代碼來源:photo_exif_date_print.py

示例15: getExif

# 需要導入模塊: from PIL.ExifTags import TAGS [as 別名]
# 或者: from PIL.ExifTags.TAGS import get [as 別名]
def getExif(image_file, save=True, verbose=True):
    '''Get image file EXIF metadata'''
    if not os.path.isfile(image_file):
        sys.exit("%s is not a valid image file!")
    data = "Time: %d/%d/%d %d : %d : %d. Found the following Exif data for the image %s:\n\n" % (now.year, now.month,
                                                                                                 now.day, now.hour, now.minute,
                                                                                                 now.second, name)
    img = Image.open(image_file)
    info = img._getexif()
    exif_data = {}
    if info:
        for (tag, value) in info.items():
            decoded = TAGS.get(tag, tag)
            if type(value) is bytes:
                try:
                    exif_data[decoded] = value.decode("utf-8")
                except:
                    pass
            else:
                exif_data[decoded] = value
    else:
        sys.exit("No EXIF data found!")

    for key in exif_data:
        data += "{}    :   {}\n".format(key, exif_data[key])

    if save:
        name = getFileName(image_file)
        tgt = name + ".txt"
        saveResult(tgt, data)

    if verbose:
        print("Found the following exif data:\n", data) 
開發者ID:MonroCoury,項目名稱:Forensic-Tools,代碼行數:35,代碼來源:exif_extractor.py


注:本文中的PIL.ExifTags.TAGS.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。