本文整理汇总了Python中models.Photo.setExif方法的典型用法代码示例。如果您正苦于以下问题:Python Photo.setExif方法的具体用法?Python Photo.setExif怎么用?Python Photo.setExif使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Photo
的用法示例。
在下文中一共展示了Photo.setExif方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadAlbum
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import setExif [as 别名]
def loadAlbum(self, path, title = None):
album = Album()
if title not in (None, ''):
album.name = title
else:
album.name = path[path.rfind(os.sep)+1:]
album.albums = {}
album.photos = []
album.path = path
files = os.listdir(path)
files.sort()
tmpPhotos = []
for fl in files:
if not os.path.isfile(path + os.sep + fl):
album.albums[fl] = self.loadAlbum(path + os.sep + fl)
else:
if self.isImageFile(path + os.sep + fl):
ph = None
if os.path.exists(path + os.sep + fl + ".sidecar"):
ph = Photo.load(path + os.sep + fl + ".sidecar")
else:
ph = Photo()
ph.comment = ""
ph.keywords = {}
ph.srcPath = None
ph.path = path + os.sep + fl
exif = loadExif(path + os.sep + fl, EXIF_TAGS)
ph.setExif(exif)
ph.save(path + os.sep + fl)
ph.path = path + os.sep + fl
tmpPhotos.append(ph)
album.photos = sorted(tmpPhotos, key = lambda photo: photo.date)
return album
示例2: doImport
# 需要导入模块: from models import Photo [as 别名]
# 或者: from models.Photo import setExif [as 别名]
def doImport(self):
libPath = getSettingStr("Paths/Library")
fileExt = getSettingStr("FileExtensions")
if libPath in (None, ''):
QMessageBox.warning(self, "Import Failed", "You need to specify a library directory in your settings")
return
if not os.path.exists(libPath) or os.path.isfile(libPath):
QMessageBox.warning(self, "Import Failed", "The library directory in your settings either doesn't exist, or its not a directory")
return
if not fileExt or fileExt in (None, ''):
QMessageBox.warning(self, "Import Failed", "You need to specify file extensions to manage in your settings")
return
lastImport = getSettingStr("Paths/LastImport")
importFrom = QFileDialog.getExistingDirectory(self, "Choose a Path to Import From", lastImport)
if importFrom in (None, ''):
return
if not os.path.exists(importFrom) or os.path.isfile(importFrom):
QMessageBox.warning(self, "Import Failed", "The import directory either doesn't exist, or is not a directory")
return
if importFrom == libPath:
QMessageBox.warning(self, "Import Failed", "Your import directory and library directory can not be the same")
return
imd = ImportMetadataDialog(self)
if imd.exec_():
album = imd.albumEdit.text()
comments = imd.commentsEdit.text()
keywords = imd.keywordsEdit.text()
if album and album not in (None, ''):
albumpath = album + os.sep
else:
album = None
albumpath = ""
if not keywords or keywords in (None, ''):
keywords = ""
if not comments or comments in (None, ''):
comments = ""
paths = self.buildFileList(importFrom)
numTotal = len(paths)
nonDupes = self.removeDuplicates(paths, importFrom, albumpath)
numDuplicates = numTotal - len(nonDupes)
if QMessageBox.question(self, "Import", "Out of %d files found, %d look to be duplicates. Continue with import?"
% (numTotal, numDuplicates), QMessageBox.Yes|QMessageBox.No) == QMessageBox.Yes:
saveSetting("Paths/LastImport", importFrom)
for path in nonDupes:
dest = self.buildLibPath(importFrom, path, albumpath)
copyFileIncludingDirectories(path, dest)
# TODO Handle copy failure exceptions!
if not os.path.exists(dest):
QMessageBox.warming(self, "Import Failed", "The file <%s> was not imported properly, aborting import" % (path))
return
if self.isImageFile(path):
exif = loadExif(unicode(path), EXIF_TAGS)
ph = Photo()
ph.path = dest
ph.srcPath = path
ph.comment = comments
ph.keywords = keywords
ph.setExif(exif)
ph.save(dest)
#Create Thumbnail
createThumbnail(unicode(ph.path))
QMessageBox.information(self, "Import", "Import completed")
self.loadLibrary()