当前位置: 首页>>代码示例>>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;未经允许,请勿转载。