当前位置: 首页>>代码示例>>Python>>正文


Python exifread.process_file方法代码示例

本文整理汇总了Python中exifread.process_file方法的典型用法代码示例。如果您正苦于以下问题:Python exifread.process_file方法的具体用法?Python exifread.process_file怎么用?Python exifread.process_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在exifread的用法示例。


在下文中一共展示了exifread.process_file方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: JPEGMeta

# 需要导入模块: import exifread [as 别名]
# 或者: from exifread import process_file [as 别名]
def JPEGMeta(image):
    """Deprecated -- This is effectively being replaced by the MultiHandler.Exif."""
    meta = ""

    # Open up the file for reading
    with open(image.veritas.file_name,"rb") as jpegFile:
            tags = exifread.process_file(jpegFile)
            
            for tag in tags:
                    meta += "{0}:\t{1}\n".format(tag,tags[tag])
    
    # Show it to the user	
    print("Exif Data\n=========\n{0}\n".format(meta))
    
    # Save it off
    with open(os.path.join(image.veritas.results_directory,"metadata"),"w") as out:
            out.write(meta) 
开发者ID:bannsec,项目名称:stegoVeritas,代码行数:19,代码来源:meta.py

示例2: process_image

# 需要导入模块: import exifread [as 别名]
# 或者: from exifread import process_file [as 别名]
def process_image(byte64_jpeg, filename):

    attch_data = str(base64.b64decode(byte64_jpeg))
    buf = cStringIO.StringIO(attch_data)

    gps = {}
    try:
        tags = exifread.process_file(buf)
    except:
        # TODO this may die because of the UNICODE set being unprintable in the console
        # print u"failed to process tags for filename {}.  Exception: {}".format(filename, sys.exc_info()[0])
        print u"failed to process tags for.  Exception: {}".format(sys.exc_info()[0])
        return gps

    if tags and len(tags) > 0:
        if "GPS GPSLatitudeRef" in tags:
            gps["latref"] = tags["GPS GPSLatitudeRef"].printable
        if "GPS GPSLongitudeRef" in tags:
            gps["lonref"] = tags["GPS GPSLongitudeRef"].printable
        if "GPS GPSAltitudeRef" in tags:
            gps["altref"] = tags["GPS GPSAltitudeRef"].printable

        if "GPS GPSLatitude" in tags:
            gps["lat"] = (1 if "latref" in gps and gps["latref"] == "N" else -1 ) * ratio_to_dms(tags["GPS GPSLatitude"].values)


        if "GPS GPSLongitude" in tags:
            gps["lon"] = (1 if "lonref" in gps and gps["lonref"] == "E" else -1 ) * ratio_to_dms(tags["GPS GPSLongitude"].values)

        if "GPS GPSAltitude" in tags:
            gps["alt"] = tags["GPS GPSAltitude"].printable

    # TODO this may die because of the UNICODE set being unprintable in the console
    # else:
    #     print u"No exif gps tags for: {} ".format(filename)

    return gps

# Validate lat lon 
开发者ID:Sotera,项目名称:pst-extraction,代码行数:41,代码来源:image_exif_processing.py

示例3: all_tags

# 需要导入模块: import exifread [as 别名]
# 或者: from exifread import process_file [as 别名]
def all_tags(path) -> {str: str}:
    """Method to return Exif tags"""
    file = open(path, "rb")
    tags = exifread.process_file(file, details=False)
    return tags 
开发者ID:openstreetcam,项目名称:upload-scripts,代码行数:7,代码来源:exif_processing.py

示例4: gps_filename_dict

# 需要导入模块: import exifread [as 别名]
# 或者: from exifread import process_file [as 别名]
def gps_filename_dict(images_list):
    """Returns the filename of the image and its GPS Coordinates
    as dictionary data structure."""

    # List which will hold the coordinate pairs and pixel values
    coordinates_dict = OrderedDict()
    # Produce the text for each image in the stack
    for file_name in images_list:
        # Open image file for reading (binary mode) and processing with PIL
        f = open(file_name, 'rb')
        # Return Exif tags
        tags = exifread.process_file(f)

        # Initializing some variables
        GPS_Longitude = 0
        GPS_Latitude = 0

        # Returns all the GPS Related Metadata
        for tag in tags.keys():

            if tag == 'GPS GPSLongitude':
                GPS_Longitude = parse_GPS_Lat_Lon(tags[tag])
                #Change from sexagesimal to decimal/degree notation
                GPS_Longitude = sexag_to_dec(GPS_Longitude)

            elif tag == 'GPS GPSLatitude':
                GPS_Latitude = parse_GPS_Lat_Lon(tags[tag])
                # Change from sexagesimal to decimal/degree notation
                GPS_Latitude = sexag_to_dec(GPS_Latitude)

            if GPS_Latitude and GPS_Longitude:
                coordinates_dict[file_name] = (GPS_Latitude, GPS_Longitude)

    return coordinates_dict


# Returns a dict of utm coord {filename: utm} 
开发者ID:Transportation-Inspection,项目名称:visual_odometry,代码行数:39,代码来源:GPS_VO.py

示例5: exif_info

# 需要导入模块: import exifread [as 别名]
# 或者: from exifread import process_file [as 别名]
def exif_info(filename):
    print ("Extraction of EXIF data from: %s" % (filename,))
    f = open(filename,'rb')
    tags = exifread.process_file(f)
    for tag in tags.keys():
        if tag not in ('JPEGThumbnail', 'TIFFThumbnail', 'Filename', 'EXIF MakerNote'):
            type_tag = tag.split(" ", 1)[0]
            tag_key = tag.split(" ", 1)[1]
            helper.sqlite_insert(tag_key,tags[tag],os.path.basename(filename))
    return filename 
开发者ID:redaelli,项目名称:imago-forensics,代码行数:12,代码来源:extractor.py

示例6: exif_creation_timestamp

# 需要导入模块: import exifread [as 别名]
# 或者: from exifread import process_file [as 别名]
def exif_creation_timestamp(path: str) -> str:
    with open(path, 'rb') as f:
        tags = exifread.process_file(f, details=False)

    if 'EXIF DateTimeOriginal' in tags:
        return str(tags['EXIF DateTimeOriginal'])
    elif 'EXIF DateTimeDigitized' in tags:
        return str(tags['EXIF DateTimeDigitized'])

    raise MissingExifTimestampError() 
开发者ID:dbader,项目名称:photosorter,代码行数:12,代码来源:sorter.py

示例7: __init__

# 需要导入模块: import exifread [as 别名]
# 或者: from exifread import process_file [as 别名]
def __init__(self, filename, details=False):
        '''
        Initialize EXIF object with FILE as filename or fileobj
        '''
        self.filename = filename
        if type(filename) == str:
            with open(filename, 'rb') as fileobj:
                self.tags = exifread.process_file(fileobj, details=details)
        else:
            self.tags = exifread.process_file(filename, details=details) 
开发者ID:mapillary,项目名称:mapillary_tools,代码行数:12,代码来源:exif_read.py

示例8: opExif

# 需要导入模块: import exifread [as 别名]
# 或者: from exifread import process_file [as 别名]
def opExif(file_path, file_name):
    # 拼接出原文件路径
    old_full_name = os.path.join(file_path, file_name)
    # 拿到原文件后缀 
    file_suffix = os.path.splitext(file_name)[1] 
    # 打开并读取文件头部的EXIF信息
    with open(old_full_name, "rb") as f:
        tags = exifread.process_file(f)

    # EXIF信息中拍摄时间的标签
    Tag = "EXIF DateTimeOriginal"
    if Tag in tags:
        # 调整原始的时间格式为"年月日_时分秒"
        file_stem = str(tags[Tag]).replace(':', '').replace(' ', '_')   
        # 新文件名:年月日_时分秒.原后缀名
        new_name = file_stem + file_suffix
        num = 1
        # 遇到拍摄时间相同则添加序号做以区分
        while os.path.exists(new_name): 
            # 新文件名:年月日_时分秒_序号.原后缀名
            new_name = file_stem + '_' + str(num) + file_suffix
            num += 1
        
        # 拼接出新文件路径
        new_full_name = os.path.join(file_path, new_name) 
        print(f"{old_full_name} >>> {new_full_name}")
        # 执行重命名操作
        os.rename(old_full_name, new_full_name) 
    else:
        print(f"No {Tag} found in: {old_full_name}")

# 修改要处理的目录 
开发者ID:MiracleYoung,项目名称:You-are-Pythonista,代码行数:34,代码来源:rename_IMG_use_Exif.py

示例9: reorient_image

# 需要导入模块: import exifread [as 别名]
# 或者: from exifread import process_file [as 别名]
def reorient_image(cls, img):
        """re-orients rotated images by looking at EXIF data
        """
        # get the image rotation from EXIF information
        import exifread

        file_full_path = img.filename

        with open(file_full_path) as f:
            tags = exifread.process_file(f)

        orientation_string = tags.get('Image Orientation')

        from PIL import Image
        if orientation_string:
            orientation = orientation_string.values[0]
            if orientation == 1:
                # do nothing
                pass
            elif orientation == 2:  # flipped in X
                img = img.transpose(Image.FLIP_LEFT_RIGHT)
            elif orientation == 3:  # rotated 180 degree
                img = img.transpose(Image.ROTATE_180)
            elif orientation == 4:  # flipped in Y
                img = img.transpose(Image.FLIP_TOP_BOTTOM)
            elif orientation == 5:  #
                img = img.transpose(Image.ROTATE_270)
                img = img.transpose(Image.FLIP_LEFT_RIGHT)
            elif orientation == 6:
                img = img.transpose(Image.FLIP_LEFT_RIGHT)
            elif orientation == 7:
                img = img.transpose(Image.ROTATE_90)
                img = img.transpose(Image.FLIP_LEFT_RIGHT)
            elif orientation == 8:
                img = img.transpose(Image.ROTATE_90)

        return img 
开发者ID:eoyilmaz,项目名称:anima,代码行数:39,代码来源:__init__.py

示例10: get_image_tags

# 需要导入模块: import exifread [as 别名]
# 或者: from exifread import process_file [as 别名]
def get_image_tags(image_path):
    f = open(image_path, 'rb')
    tags = exifread.process_file(f)
    return tags 
开发者ID:AbdoKamel,项目名称:simple-camera-pipeline,代码行数:6,代码来源:pipeline_utils.py

示例11: __get_image_ability

# 需要导入模块: import exifread [as 别名]
# 或者: from exifread import process_file [as 别名]
def __get_image_ability(self):
        """
        获取图片的属性值,包含:经纬度、拍摄时间等
        :param picture_name:
        :return:
        """

        # 利用exifread库,读取图片的属性
        img_exif = exifread.process_file(open(self.img_path, 'rb'))

        # 能够读取到属性
        if img_exif:
            # 纬度数
            latitude_gps = img_exif['GPS GPSLatitude']

            # N,S 南北纬方向
            latitude_direction = img_exif['GPS GPSLatitudeRef']

            # 经度数
            longitude_gps = img_exif['GPS GPSLongitude']

            # E,W 东西经方向
            longitude_direction = img_exif['GPS GPSLongitudeRef']

            # 拍摄时间
            take_time = img_exif['EXIF DateTimeOriginal']

            is_lie = self.judge_time_met(take_time)

            if is_lie:
                print('很遗憾的通知你,你的女朋友在撒谎!!!')
                return

                # 纬度、经度、拍摄时间
            if latitude_gps and longitude_gps and take_time:

                # 对纬度、经度值原始值作进一步的处理
                latitude = self.__format_lati_long_data(latitude_gps)
                longitude = self.__format_lati_long_data(longitude_gps)

                # print(f'{longitude},{latitude}')

                # 注意:由于gps获取的坐标在国内高德等主流地图上逆编码不够精确,这里需要转换为火星坐标系
                location = wgs84togcj02(longitude, latitude)

                return f'{location[0]},{location[1]}'
            else:
                print(f'获取的图片数据属性不完整')
                return ''
        else:
            print('抱歉,图片不是原图,没法获取到图片属性。')
            return '' 
开发者ID:xingag,项目名称:spider_python,代码行数:54,代码来源:main.py


注:本文中的exifread.process_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。