apng: Convert static pngs to animated png

Description Usage Arguments Value Examples

View source: R/apng.R

Description

Combine multiple png files into an animated png file.

Usage

1
2
3
4
apng(input_files = c(), output_file = "output.png",
num_plays = 0, delay_num = 0, delay_den = 0,
dispose_op = APNG_DISPOSE_OP_NONE,
blend_op = APNG_BLEND_OP_SOURCE)

Arguments

input_files

to specify the names of the input files

output_file

the name of the output file

num_plays

the amount of times to repeat the animation (0 means forever)

delay_num

the numerator of the frame delay (delay = delay_num / delay_den)

delay_den

the denominator of the frame delay (delay = delay_num / delay_den)

dispose_op

the frame disposal strategy
(APNG_DISPOSE_OP_NONE, APNG_DISPOSE_OP_BACKGROUND,
APNG_DISPOSE_OP_PREVIOUS)

blend_op

the frame blending strategy
(APNG_BLEND_OP_SOURCE, APNG_BLEND_OP_OVER)

For more information on blending and frame disposal strategies see https://wiki.mozilla.org/APNG_Specification.

Value

Returns nothing, output is written to output_file.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
input1 <- tempfile(pattern = "", fileext = ".png")
input2 <- tempfile(pattern = "", fileext = ".png")
output <- tempfile(pattern = "", fileext = ".png")

# Generate inputs.
png(filename=input1)
plot(1:40, (1:40)^2)
dev.off()
png(filename=input2)
plot(1:40, (-1*1:40)^3)
dev.off()

# Create an animated png.
apng(c(input1, input2), output)

Example output

Loading required package: bitops
png 
  2 
png 
  2 
Warning messages:
1: In READ_PNG(file_input) :
  PNG CONTAINS A PALETTE, PALETTE-LESS PNG (ex. png(type="cairo-png")) IS VERY MUCH SUGGESTED
2: In READ_PNG(file_input) :
  PNG CONTAINS A PALETTE, PALETTE-LESS PNG (ex. png(type="cairo-png")) IS VERY MUCH SUGGESTED

apng documentation built on Jan. 16, 2021, 5:40 p.m.