Package 'apng'

Title: Convert Png Files into Animated Png
Description: Convert several png files into an animated png file. This package exports only a single function `apng'. Call the apng function with a vector of file names (which should be png files) to convert them to a single animated png file.
Authors: Quinten Stokkink
Maintainer: Quinten Stokkink <[email protected]>
License: GPL-3 | file LICENSE
Version: 1.1
Built: 2024-11-16 06:33:37 UTC
Source: CRAN

Help Index


Convert Png Files into Animated Png

Description

Convert several png files into an animated png file. This package exports only a single function ‘apng’. Call the apng function with a vector of file names (which should be png files) to convert them to a single animated png file.

Note

The CRC implementation in this package was adopted from the W3 Portable Network Graphics (PNG) Specification (Second Edition): Annex D - Sample Cyclic Redundancy Code implementation. As such, special thanks go out to the authors of the specification: https://www.w3.org/TR/PNG/#F-Relationship.

Author(s)

Quinten Stokkink

Maintainer: Quinten Stokkink <[email protected]>

References

https://www.w3.org/TR/PNG/
https://wiki.mozilla.org/APNG_Specification


Convert static pngs to animated png

Description

Combine multiple png files into an animated png file.

Usage

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_numdelay_dendelay = \frac{delay\_num}{delay\_den})

delay_den

the denominator of the frame delay (delay=delay_numdelay_dendelay = \frac{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

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)

Blend previous frame into alpha

Description

When rendering a new frame, the previous frame is filled into the alpha of the new frame. For example, 50% red over blue makes purple.

Value

1


Completely replace the previous frame

Description

When rendering a new frame, the region is filled as specified exactly by the new frame. For example, 50% red over blue makes 50% red over the background.

Value

0


Prepare region as fully transparent

Description

Before a new frame is rendered, the region is replaced by the background color.

Value

1


Write over the current output buffer

Description

Nothing is done to the existing buffer when a new frame is rendered.

Value

0


Keep previous frame in rendering region

Description

Before a new frame is rendered, the region is restored to what it was before the previous frame.

Value

2