image.py 文件源码

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

项目:pcbot 作者: pckv 项目源码 文件源码
def modify(self, function, *args, **kwargs):
        """ Modify the image object using the given Image function.
        This function supplies sequence support. """
        if not gif_support or not self.gif:
            self.object = function(self.object, *args, **kwargs)
        else:
            frames = []
            duration = self.object.info.get("duration") / 1000
            for frame in ImageSequence.Iterator(self.object):
                frame_bytes = utils.convert_image_object(function(frame, *args, **kwargs))
                frames.append(imageio.imread(frame_bytes, format="PNG"))

            # Save the image as bytes and recreate the image object
            image_bytes = imageio.mimwrite(imageio.RETURN_BYTES, frames, format=self.format, duration=duration)
            self.object = Image.open(BytesIO(image_bytes))
            self.gif_bytes = image_bytes
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号