GVKun编程网logo

以编程方式在Python中生成视频或动画GIF?(编程python如何制作动画)

8

对于想了解以编程方式在Python中生成视频或动画GIF?的读者,本文将提供新的信息,我们将详细介绍编程python如何制作动画,并且为您提供关于c#–以编程方式在Button中添加图像、Python

对于想了解以编程方式在Python中生成视频或动画GIF?的读者,本文将提供新的信息,我们将详细介绍编程python如何制作动画,并且为您提供关于c# – 以编程方式在Button中添加图像、Python unittest:以编程方式生成多个测试?、python-如何以编程方式在jenkins作业配置页面中设置github repo、以编程方式停止GIF动画的有价值信息。

本文目录一览:

以编程方式在Python中生成视频或动画GIF?(编程python如何制作动画)

以编程方式在Python中生成视频或动画GIF?(编程python如何制作动画)

我有一系列要用来创建视频的图像。理想情况下,我可以为每个帧指定一个帧持续时间,但是固定帧速率也可以。我正在wxPython中执行此操作,因此可以渲染到wxDC,也可以将图像保存到文件中,例如PNG。是否有Python库可让我根据这些帧创建视频(AVI,MPG等)或动画GIF?

答案1

小编典典

我建议不要使用visvis中的images2gif,因为它在PIL / Pillow方面存在问题,并且没有得到积极维护(我应该知道,因为我是作者)。

相反,请使用imageio,它是为解决此问题而开发的,并且打算保留下来。

快速而肮脏的解决方案:

import imageioimages = []for filename in filenames:    images.append(imageio.imread(filename))imageio.mimsave(''/path/to/movie.gif'', images)

对于更长的电影,请使用流媒体方法:

import imageiowith imageio.get_writer(''/path/to/movie.gif'', mode=''I'') as writer:    for filename in filenames:        image = imageio.imread(filename)        writer.append_data(image)

c# – 以编程方式在Button中添加图像

c# – 以编程方式在Button中添加图像

在 WPF中:
<Button Width="24" Height="24" >
    <Image Source="pack://application:,/res/x.png" VerticalAlignment="Center"/>
</Button>

我怎样才能在C#中模仿这个?我在Button类中找不到添加子项的任何方法.

解决方法

Button是一个Content控件,因此您只需使用Buttons Content属性

例:

Button myButton = new Button
{
    Width = 24,Height = 24,Content = new Image
    {
        Source = new BitmapImage(new Uri("image source")),VerticalAlignment = VerticalAlignment.Center
    }
};

Python unittest:以编程方式生成多个测试?

Python unittest:以编程方式生成多个测试?

我有一个要测试的函数under_test,和一组预期的输入/输出对:

[
(2,332),(234,99213),(9,3),# ...
]

我希望这些输入/输出对中的每一个都可以用自己的test_*方法进行测试。那可能吗?

这是我想要的,但是将每个输入/输出对强制进行单个测试:

class TestPreReqs(unittest.TestCase):

    def setUp(self):
        self.expected_pairs = [(23,55),(4,32)]

    def test_expected(self):
        for exp in self.expected_pairs:
            self.assertEqual(under_test(exp[0]),exp[1])

if __name__ == '__main__':
    unittest.main()

(此外,我是否真的想将self.expected_pairsin的定义放在setUp?)

更新: 尝试 doublep 的建议:

class TestPreReqs(unittest.TestCase):

    def setUp(self):
        expected_pairs = [
                          (2,(42,11),(3,None),(31,99),]

        for k,pair in expected_pairs:
            setattr(TestPreReqs,'test_expected_%d' % k,create_test(pair))

    def create_test (pair):
        def do_test_expected(self):
            self.assertEqual(get_pre_reqs(pair[0]),pair[1])
        return do_test_expected


if __name__ == '__main__':
    unittest.main()

这是行不通的。运行0个测试。我是否对示例进行了错误的修改?

python-如何以编程方式在jenkins作业配置页面中设置github repo

python-如何以编程方式在jenkins作业配置页面中设置github repo

我想在每次生成新的Jenkins容器时通过代码在http://host-ip:8080/job/my_project/configure jenkins页面中设置Github存储库URL.

我读到可以用python-jenkins的reconfig_job function替换config.xml来完成.

好吧,我该怎么做?

最佳答案
您在“ How can I update a jenkins job using the api?”中有一些线索

例如,由于您生成了一个新的Jenkins容器,因此您可以docker cp将一个更新的config.xml添加到该容器中(该作业的正确路径)

(当在git bash中运行时,OP Kostas Demiris确认in the comments可以工作)

您也可以使用Jenkins API libraries之一,但请检查是否为simple curl is enough first

#Get the current configuration and save it locally
curl -X GET http://user:password@jenkins.server.org/job/myjobname/config.xml -o mylocalconfig.xml

#Update the configuration via posting a local configuration file
curl -X POST http://user:password@jenkins.server.org/job/myjobname/config.xml --data-binary "@mymodifiedlocalconfig.xml"

updated Jenkins doc mentions(用于仅更新现有配置作业中的一个参数):

Simple example - sending "String Parameters":

curl -X POST JENKINS_URL/job/JOB_NAME/build \
  --data token=TOKEN \
  --data-urlencode json='{"parameter": [{"name":"id","value":"123"},{"name":"verbosity","value":"high"}]}'

Another example - sending a "File Parameter":

curl -X POST JENKINS_URL/job/JOB_NAME/build \
  --user USER:PASSWORD \
  --form file0=@PATH_TO_FILE \
  --form json='{"parameter": [{"name":"FILE_LOCATION_AS_SET_IN_JENKINS","file":"file0"}]}'

以编程方式停止GIF动画

以编程方式停止GIF动画

我正在开发一个Twitter应用程序,该应用程序直接从Twitter引用图像。如何防止动画gif播放?

window.stop()在页面末尾使用不适用于Firefox。

是否有更好的JavaScript技巧?最好对所有浏览器都适用

今天关于以编程方式在Python中生成视频或动画GIF?编程python如何制作动画的介绍到此结束,谢谢您的阅读,有关c# – 以编程方式在Button中添加图像、Python unittest:以编程方式生成多个测试?、python-如何以编程方式在jenkins作业配置页面中设置github repo、以编程方式停止GIF动画等更多相关知识的信息可以在本站进行查询。

本文标签: