本文整理汇总了Python中photo.Photo.filepath方法的典型用法代码示例。如果您正苦于以下问题:Python Photo.filepath方法的具体用法?Python Photo.filepath怎么用?Python Photo.filepath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类photo.Photo
的用法示例。
在下文中一共展示了Photo.filepath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_avatar
# 需要导入模块: from photo import Photo [as 别名]
# 或者: from photo.Photo import filepath [as 别名]
def save_avatar(self, filepath):
photo = Photo()
photo.filepath = filepath
photo.us_id = self.id
DBSession.add(photo)
DBSession.flush()
return photo
示例2: save_photo
# 需要导入模块: from photo import Photo [as 别名]
# 或者: from photo.Photo import filepath [as 别名]
def save_photo(self, filepath, main=False):
photo = Photo()
photo.filepath = filepath
photo.product_id = self.id
photo.is_main = main
DBSession.add(photo)
DBSession.flush()
return photo
示例3: save_event_photo
# 需要导入模块: from photo import Photo [as 别名]
# 或者: from photo.Photo import filepath [as 别名]
def save_event_photo(cls, event_id, photo):
if type(photo) is type(''):
return False
file_content = photo.file.read()
if len(file_content) == 0:
return False
filename, ext = os.path.splitext(photo.filename)
filename = unicodedata.normalize('NFD', filename).encode('ascii', 'ignore')
md5_ = md5(str(file_content)).hexdigest()
new_filename = md5_ + '_' + filename.lower() + ext.lower()
if not os.path.exists(Photo.BASE_STORAGE_PATH + new_filename[0]):
os.makedirs(Photo.BASE_STORAGE_PATH + new_filename[0])
new_filename_with_path = Photo.BASE_STORAGE_PATH + new_filename[0] + '/' + new_filename
Photo.save_original(new_filename_with_path, file_content)
img = Image.open(new_filename_with_path)
if img.mode != "RBG":
img = img.convert("RGB")
tiny_image = Photo.resize(img, Photo.TINY_THUMBNAIL, new_filename, 'tiny_')
small_image = Photo.resize(img, Photo.SMALL_THUMBNAIL, new_filename, 'small_')
big_image = Photo.resize(img, Photo.BIG_THUMBNAIL, new_filename, 'big_')
maxi_image = Photo.resize(img, Photo.MAXI_THUMBNAIL, new_filename, 'maxi_')
photo = Photo()
photo.filepath = new_filename_with_path
photo.event_id = event_id
photo.is_main = True
DBSession.add(photo)
DBSession.flush()
return photo