Ejemplo n.º 1
0
    def _createDate(self, files):
        if not files:
            return

        data = []
        for i in range(len(files)):
            file = files[i]
            size = Utils.getFileInfo(file)['文件大小']
            ct = Utils.getFileInfo(file)['最后一次的修改时间']
            data.append([files[i], '', '', size, ct])
        return data
Ejemplo n.º 2
0
    def __show_photo_exif(self):
        if not self.photo_file:
            return

        try:
            # with open(self.photo_file.encode('utf-8'), 'rb') as f:
            #     tags = exifread.process_file(f)
            tags = self.get_exif_data(self.photo_file)

            # keys = [r'DateTimeOriginal', 'Make', r'Model', r'FocalLength', r'LensModel']
            # tags = self._get_some_exifs(self.photo_file, keys)
            # print('here', tags)
            # for tag, value in tags.items():
            #     if re.match('Image Make', tag):
            #         print('[*] 品牌信息: ' + str(value))
            #     if re.match('Image Model', tag):
            #         print('[*] 具体型号: ' + str(value))
            #     if re.match('EXIF LensModel', tag):
            #         print('[*] 摄像头信息: ' + str(value))
            # if re.match('GPS GPSLatitudeRef', tag):
            #     GPS['GPSLatitudeRef'] = str(value)
            # elif re.match('GPS GPSLongitudeRef', tag):
            #     GPS['GPSLongitudeRef'] = str(value)
            # elif re.match('GPS GPSAltitudeRef', tag):
            #     GPS['GPSAltitudeRef'] = str(value)
            # elif re.match('GPS GPSLatitude', tag):

            if not tags:
                self.lb_photo_time.setText(f"拍摄时间:")
                self.lb_camera.setText(f"相机厂商:")
                self.lb_model.setText(f"相机型号:")

                img = QtGui.QImage(self.photo_file)
                size = Utils.getFileInfo(self.photo_file)['文件大小']
                self.lb_weight.setText(f"文件大小:{size}")
                self.lb_photo_size.setText(f"相片尺寸:{img.width(), img.height()}")
                self.lb_resolution.setText(f"分辨率单位:{'像素'}")
                # print('width=', img.width())
                return

            # 打印照片其中一些信息
            creat_time = tags['DateTimeOriginal']
            # print('here', (creat_time))
            maker, model = tags['Make'], tags['Model']
            self.lb_photo_time.setText(f"拍摄时间:{creat_time}")
            self.lb_camera.setText(f"相机厂商:{maker}")
            self.lb_model.setText(f"相机型号:{model}  焦距:{tags['FocalLength']}")
            # print('time:', creat_time)

            w = tags['ExifImageWidth']
            h = tags['ExifImageHeight']
            r = tags['ResolutionUnit']
            # size = int(w) * h
            unit = ['', '像素/Pixels', '英寸/Inch']
            size = Utils.getFileInfo(self.photo_file)['文件大小']
            self.lb_weight.setText(f"文件大小:{size}")
            self.lb_photo_size.setText(f"相片尺寸:{w, h}")
            self.lb_resolution.setText(f"分辨率单位:{unit[r]}")

            # lat_ref = tags["GPS GPSLatitudeRef"].printable
            # lat = tags["GPS GPSLatitude"].printable[1:-1].replace(" ", "").replace("/", ",").split(",")
            # lat = float(lat[0]) + float(lat[1]) / 60 + float(lat[2]) / float(lat[3]) / 3600
            # if lat_ref != "N":
            #     lat = lat * (-1)
            # # 经度
            # lon_ref = tags["GPS GPSLongitudeRef"].printable
            # lon = tags["GPS GPSLongitude"].printable[1:-1].replace(" ", "").replace("/", ",").split(",")
            # lon = float(lon[0]) + float(lon[1]) / 60 + float(lon[2]) / float(lon[3]) / 3600
            # if lon_ref != "E":
            #     lon = lon * (-1)
        except KeyError:
            return "ERROR:请确保照片包含经纬度等EXIF信息。"