def create_thumb_js(self, mode=None, pth=None):
""" Create the thumbnail using SmartCrop.js """
if pth is None:
raise ValueError("path can't be None")
# save a copy of the image with the correct orientation in a temporary
# file
_, tmpfname = tempfile.mkstemp(suffix='.'+settings.output_format)
self.original_image.save(tmpfname, quality=95)
# Load smartcrop and set options
nwidth, nheight = self.resize_dims(mode)
logging.info("[%s] SmartCrop.js new dimensions: %ix%i" % (self.name,
nwidth, nheight))
command = [settings.smartcrop_js_path, '--width', str(nwidth),
'--height', str(nheight), tmpfname, pth]
logging.info("[%s] SmartCrop.js running crop command." % self.name)
check_output(command)
# remove the temporary file
os.remove(tmpfname)
return pth
评论列表
文章目录