Title: | Read and Write QOI Images |
---|---|
Description: | The new QOI file format offers a very simple but efficient image compression algorithm. This package provides an easy and simple way to read, write and display bitmap images stored in the QOI (Quite Ok Image) format. It can read and write both files and in-memory raw vectors. |
Authors: | Johannes Friedrich [aut, trl, cre], Dominic Szablewski [cph] (C library 'qoi') |
Maintainer: | Johannes Friedrich <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1 |
Built: | 2025-01-29 22:12:49 UTC |
Source: | https://github.com/johannesfriedrich/qoi4r |
Read an QOI image into a RGB(A) raster array
readQOI(qoi_image_path)
readQOI(qoi_image_path)
qoi_image_path |
character (required): Path to a stored qoi-image |
A matrix with integer (0-255) RGB(A) values with dimensions height x width x channels. Until now 3 (RGB) and 4 (RGBA) channels are integrated in the specification. If the decoding went wrong the returned value is NULL.
Johannes Friedrich
## (1) Read RGBA values from file path <- system.file("extdata", "Rlogo.qoi", package="qoi") rlogo_qoi <- readQOI(path) dim(rlogo_qoi) ## (2) plot them plot.new()
## (1) Read RGBA values from file path <- system.file("extdata", "Rlogo.qoi", package="qoi") rlogo_qoi <- readQOI(path) dim(rlogo_qoi) ## (2) plot them plot.new()
RGBA values for the Rlogo (https://www.r-project.org/logo/)
[matrix] with 561 x 724 x 4 elements
Johannes Friedrich
Write an QOI image from an RGB(A) raster array or matrix
writeQOI(image, target = raw())
writeQOI(image, target = raw())
image |
matrix (required): Image represented by a integer matrix or array with values in the range of 0 to 255. |
target |
character or connections or raw: Either name of the file to write, a binary connection or a raw vector (raw() - the default - is good enough) indicating that the output should be a raw vector. |
The result is either stored in a file (if target is a file name), in a raw vector (if target is a raw vector) or sent to a binary connection.
Johannes Friedrich
## (1) Write to raw() -> see bytes bin <- writeQOI(Rlogo_RGBA) rawToChar(head(bin)) ## qoif ## Not run: ## (2) Write to a *.qoi file writeQOI(Rlogo_RGBA, "Rlogo_RGBA.qoi") ## End(Not run)
## (1) Write to raw() -> see bytes bin <- writeQOI(Rlogo_RGBA) rawToChar(head(bin)) ## qoif ## Not run: ## (2) Write to a *.qoi file writeQOI(Rlogo_RGBA, "Rlogo_RGBA.qoi") ## End(Not run)