小编Dra*_*421的帖子

用 Pillow 阅读的 Gif 有黑色边框

我正在使用 Pillow 读取 gif,此代码将 gif 文件中的每一帧输出为 .gif 和 .png,并转换为 RGBA 和不转换为 RGBA。

在显示结果后,我将讨论下面的问题

from PIL import Image

# Download link below
image = Image.open('PepePls.gif')

loop = []
frames = []
durations = []
try:
    while True:
        loop.append(image.info.get('loop', None))
        frame = image.copy()
        frames.append(frame)
        durations.append(image.info.get('duration', None))
        image.seek(image.tell() + 1)
except EOFError:
    pass

for i in range(len(frames)):
    print(f'#{i} loop = {loop[i]} duration = {durations[i]} mode = {frames[i].mode}')
    frames[i].save(f'gif_f{i}.gif')
    frames[i].save(f'png_f{i}.png')
    frames[i].convert(mode='RGBA').save(f'rgba_gif_f{i}.gif')
    frames[i].convert(mode='RGBA').save(f'rgba_png_f{i}.png')
Run Code Online (Sandbox Code Playgroud)

结果,控制台输出然后 explorer.exe 截图:

#0 loop = 0 duration = 70 mode = …
Run Code Online (Sandbox Code Playgroud)

python gif animated-gif python-imaging-library

5
推荐指数
1
解决办法
555
查看次数

如何调试 Firefox 扩展,它似乎无声地崩溃

我不知道如何调试我的简单扩展。脚本(内容脚本)加载(因为第一个 console.log 调用显示在选项卡的控制台中),但随后什么也没有。没有任何错误,也没有第二次 console.log 调用。

我的问题不是关于解决我的代码问题(肯定有一个,如果只有 Firefox 能告诉我在哪里),而是关于找到有关附加组件的警告/错误在 Firefox 中的位置(例如 'sdfsdf has no object property )。 ..')

about:调试没有帮助,它可以打开的控制台显示一些错误(例如:“错误:服务“domainInfo”不可用。请确保它出现在使用它的模块背景的“requiresServices”属性中。”)这与我想做的事情无关(我可以从错误的来源和性质中看出)

// start of file
console.log('I AM LOADING');
// simple DOM manipulation code here...
console.log('I AM LOADED');
// end of file
Run Code Online (Sandbox Code Playgroud)

debugging firefox firefox-addon

4
推荐指数
1
解决办法
1214
查看次数