小编Dav*_*ard的帖子

Python ImageIO中动画Gif的自定义帧持续时间

我一直在玩Python中的GIF动画,框架将由位于温室中的Raspberry Pi相机生成.我使用了Almar对前一个问题的回答推荐的imageio代码,成功创建了简单的GIF.

但是,我现在正试图减慢帧持续时间但是查看imageio文档并且找不到mimsave的任何引用但是看到mimwrite,它应该采用四个args.我查看了额外的gif文档,可以看到有一个持续时间参数.

目前,我的代码如下:

exportname = "output.gif"
kargs = { 'duration': 5 }
imageio.mimsave(exportname, frames, 'GIF', kargs)
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

Traceback (most recent call last):
File "makegif.py", line 23, in <module>
imageio.mimsave(exportname, frames, 'GIF', kargs)
TypeError: mimwrite() takes at most 3 arguments (4 given)
Run Code Online (Sandbox Code Playgroud)

其中frames是imageio.imread对象的列表.为什么是这样?

更新显示完整的答案:这是一个示例,显示如何使用kwargs创建带有imageio的GIF动画来更改帧持续时间.

import imageio
import os
import sys

if len(sys.argv) < 2:
  print("Not enough args - add the full path")

indir = sys.argv[1]

frames = []

# Load …
Run Code Online (Sandbox Code Playgroud)

python animation image

8
推荐指数
3
解决办法
1万
查看次数

Django 管理拖放

寻求一些指导,因为就我的 Django 经验而言,我正在进入新领域。我正在编写一个复印请求应用程序,因此创建了几个模型:

class Job(models.Model):
  id = models.AutoField(primary_key=True) # AutoField?


class Resource(models.Model):
  id = models.AutoField(primary_key=True) # AutoField?
  job = models.ForeignKey(Job)
  file = models.FileField(upload_to="repro/")
Run Code Online (Sandbox Code Playgroud)

管理视图包含内联资源

class ResourceInline(admin.TabularInline):
        model = Resource
        extra = 0

class JobAdmin(admin.ModelAdmin):
    model = Job
    list_display = ['requestedby','account','requestdate','requireddate','noofsides','noofcopies']
    list_filter = ['requireddate']
    search_fields = ['requestedby','account']
    form = JobForm
    fieldsets = [
        (None, {'fields': ['requestedby','account','requestdate','requireddate','noofsides','noofcopies'] }),
        ('Requirements', {'fields': ['color','sided','paper','finishing']}),
        ('Additional Information', {'fields': ['additionalinfo']}),

    ]
    inlines = [ResourceInline]
admin.site.register(Job,JobAdmin)
Run Code Online (Sandbox Code Playgroud)

我计划使用dropzone.js并为自己准备了一个可以自定义的change_form.html,但此时我有点迷失了。如何用我的拖放区替换内联并使其正常工作?

感谢您的任何帮助或指点。

克里斯

python django drag-and-drop django-admin python-3.x

6
推荐指数
1
解决办法
4352
查看次数