read_webp: Webp image format

Description Usage Arguments Examples

View source: R/webp.R

Description

Read and write webp images into a bitmap array. The bitmap array uses the same conventions as the png and jpeg package.

Usage

1
2
3
read_webp(source, numeric = TRUE)

write_webp(image, target = NULL, quality = 80)

Arguments

source

raw vector or path to webp file

numeric

convert the image to 0-1 real numbers to be compatible with images from the jpeg or png package.

image

array of 3 dimensions (width * height * channel) with real numbers between 0 and 1.

target

path to a file or NULL to return the image as a raw vector

quality

value between 0 and 100

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# Convert to webp
library(png)
img <- readPNG(system.file("img", "Rlogo.png", package="png"))
out <- file.path(tempdir(), "rlogo.webp")
write_webp(img, out)
# browseURL(out)

# Convert from webp
library(jpeg)
img <- read_webp(out)
jpeg <- file.path(tempdir(), "rlogo.jpeg")
writeJPEG(img, jpeg)
# browseURL(jpeg)

jeroen/webp documentation built on May 19, 2019, 6:10 a.m.