本文整理匯總了Python中photo.Photo.saveThumb方法的典型用法代碼示例。如果您正苦於以下問題:Python Photo.saveThumb方法的具體用法?Python Photo.saveThumb怎麽用?Python Photo.saveThumb使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類photo.Photo
的用法示例。
在下文中一共展示了Photo.saveThumb方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: scaleImage
# 需要導入模塊: from photo import Photo [as 別名]
# 或者: from photo.Photo import saveThumb [as 別名]
def scaleImage(filename, filigrane=None):
"""Common processing for one image :
- create a subfolder "scaled" and "thumb"
- populate it
@param filename: path to the file
@param filigrane: None or a Signature instance (see imagizer.photo.Signature)
"""
rootdir = os.path.dirname(filename)
scaledir = os.path.join(rootdir, config.ScaledImages["Suffix"])
thumbdir = os.path.join(rootdir, config.Thumbnails["Suffix"])
fileutils.mkdir(scaledir)
fileutils.mkdir(thumbdir)
photo = Photo(filename, dontCache=True)
param = config.ScaledImages.copy()
param.pop("Suffix")
param["strThumbFile"] = os.path.join(scaledir, os.path.basename(filename))[:-4] + "--%s.jpg" % config.ScaledImages["Suffix"]
photo.saveThumb(**param)
param = config.Thumbnails.copy()
param.pop("Suffix")
param["strThumbFile"] = os.path.join(thumbdir, os.path.basename(filename))[:-4] + "--%s.jpg" % config.Thumbnails["Suffix"]
photo.saveThumb(**param)
if filigrane is not None:
filigrane.substract(photo.pil).save(filename, quality=config.FiligraneQuality, optimize=config.FiligraneOptimize, progressive=config.FiligraneOptimize)
try:
os.chmod(filename, config.DefaultFileMode)
except OSError:
logger.warning("in scaleImage: Unable to chmod %s" % filename)