我尝试在线阅读大量示例,发现imageio
是完美的一揽子计划。 Also found examples written in here。
我刚刚按照图示示例并尝试了以下
import imageio as io
import os
file_names = sorted((fn for fn in os.listdir('.') if fn.startswith('surface')))
#making animation
with io.get_writer('surface.gif', mode='I', duration=0.5) as writer:
for filename in file_names:
image = io.imread(filename)
writer.append_data(image)
writer.close()
和另一个例子。
images = []
for filename in file_names:
images.append(io.imread(filename))
io.mimsave('surface1.gif', images, duration = 0.5)
这两个都行不通。基本上我只看到gif中的第一帧并且眨眼并完成。持续时间设置为0.5秒,所以它应该工作正常。我可能错过了这里的一些东西。
答案 0 :(得分:7)
这对我有用:
import os
import imageio
png_dir = '../saves/png/'
images = []
for file_name in os.listdir(png_dir):
if file_name.endswith('.png'):
file_path = os.path.join(png_dir, file_name)
images.append(imageio.imread(file_path))
imageio.mimsave('../saves/gif/movie.gif', images)
答案 1 :(得分:0)
万一有人需要,
对于python 3.6.8,它需要library(shinydashboard)
shinyApp(
ui = fluidPage(
splitLayout(
valueBoxOutput("box1"),
valueBoxOutput("box2"),
valueBoxOutput("box3"),
valueBoxOutput("box4"),
valueBoxOutput("box5"),
valueBoxOutput("box6"),
valueBoxOutput("box7"),
valueBoxOutput("box8")
)
),
server = function(input, output){
output$box1 <- renderInfoBox({
infoBox(
"box1",
"A",
icon = icon("credit-card")
)
})
output$box2 <- renderInfoBox({
infoBox(
"box2",
"B",
icon = icon("credit-card")
)
})
output$box3 <- renderInfoBox({
infoBox(
"box3",
"C",
icon = icon("credit-card")
)
})
output$box4 <- renderInfoBox({
infoBox(
"box4",
"D",
icon = icon("credit-card")
)
})
output$box5 <- renderInfoBox({
infoBox(
"box5",
"E",
icon = icon("credit-card")
)
})
output$box6 <- renderInfoBox({
infoBox(
"box6",
"F",
icon = icon("credit-card")
)
})
output$box7 <- renderInfoBox({
infoBox(
"box7",
"G",
icon = icon("credit-card")
)
})
output$box8 <- renderInfoBox({
infoBox(
"box8",
"H",
icon = icon("credit-card")
)
})
}
)
fps