Package 'qoi'

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

Help Index


Read an QOI image into a RGB(A) raster array

Description

Read an QOI image into a RGB(A) raster array

Usage

readQOI(qoi_image_path)

Arguments

qoi_image_path

character (required): Path to a stored qoi-image

Value

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.

Author(s)

Johannes Friedrich

Examples

## (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/)

Description

RGBA values for the Rlogo (https://www.r-project.org/logo/)

Format

[matrix] with 561 x 724 x 4 elements

Author(s)

Johannes Friedrich


Write an QOI image from an RGB(A) raster array or matrix

Description

Write an QOI image from an RGB(A) raster array or matrix

Usage

writeQOI(image, target = raw())

Arguments

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.

Value

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.

Author(s)

Johannes Friedrich

Examples

## (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)