photo.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:HugoPhotoSwipe 作者: GjjvdBurg 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号