Package 'kraw'

Title: Explore CR2 Raw Images
Description: Read, extract & visualize metadata information from CR2 raw camera images.
Authors: Philippe Peret [aut, cre, cph] (ORCID: <https://orcid.org/0009-0003-9666-7490>)
Maintainer: Philippe Peret <[email protected]>
License: GPL-3 + file LICENSE
Version: 0.9.0
Built: 2026-10-05 16:33:19 UTC
Source: https://github.com/thekangaroofactory/kraw

Help Index


Image File Directory

Description

Image File Directory

Usage

ifd(x, offset = 1)

Arguments

x

a raw vector.

offset

an integer to indicate where the sequence starts.

Details

The output list contains:

  • nb_entries: the number of entries

  • entries: the entries

  • offset_next_ifd: offset to the next ifd.

Value

a list with the IFD information.

Examples

## Not run: 
ifd(x, offset = 924)

## End(Not run)

IFD Entry Value or Offset

Description

IFD Entry Value or Offset

Usage

ifd_entry(ifd, id, raw_vector = NULL, verbose = FALSE)

Arguments

ifd

an IFD list.

id

the id of the entry.

raw_vector

the raw vector to extract value when an offset is involved.

verbose

whether to turn ON/OFF console log.

Details

ifd expects a list as returned by the ifd() function.

Value

a numeric value or a vector with the offset.

See Also

ifd()

Examples

## Not run: 
ifd_entry(ifd, id = "0100")

## End(Not run)

Most Frequent

Description

Extract most frequent combination.

Usage

most_frequent(data)

Arguments

data

a data.frame (output of scan()).

Details

The function computes the most frequent combination over: camera, orientation, exposure_time, f_number, iso_speed, lens_model, focal_length

Value

a data.frame.

Examples

## Not run: 
most_frequent(scan("."))

## End(Not run)

Order Bytes

Description

Order Bytes

Usage

order_bytes(x, endian = "II")

Arguments

x

a vector or data.frame of bytes.

endian

the endianess.

Details

When x is a data.frame, value will be a data.frame, each row being the concatenation of the ordered columns.

Only little endian (i.e. "II") is supported.

Value

the corresponding hexadecimal vector or data.frame.

Examples

## Not run: 
order_bytes(x, endian = "II")

## End(Not run)

Aperture Plot

Description

Aperture Plot

Usage

p_aperture(data, fg = "grey", bg = "grey", theme = p_theme())

Arguments

data

a data.frame (see details).

fg

a foreground color.

bg

a background color.

theme

an optional theme function.

Details

data expects the following columns:

  • lens_model: character, the name of the lens

  • f_number: character, the aperture value

Value

a 'ggplot' object.

Examples

## Not run: 
p_aperture(data)

## End(Not run)

Camera Plot

Description

Camera Plot

Usage

p_camera(data, fg = NA, bg = "grey", theme = p_theme())

Arguments

data

a data.frame (see details).

fg

a foreground color.

bg

a background color.

theme

an optional theme function.

Details

data expects a data.frame with the following columns:

  • camera: character, the camera name

  • n: numeric, the number of images for the camera

Value

a 'ggplot' object.

See Also

p_theme()

Examples

p_camera(data.frame(camera = "Canon EOS 70D", n = 10))

Focal Length Plot

Description

Focal Length Plot

Usage

p_focal(data, fg = "grey", bg = "grey", theme = p_theme())

Arguments

data

a data.frame (see details).

fg

a foreground color.

bg

a background color.

theme

an optional theme function.

Details

data expects the following columns:

  • lens_model: character, the name of the lens

  • focal_length: numeric, the focal length

  • n: the number of images.

Value

a 'ggplot' object.

Examples

## Not run: 
p_focal(data = metadata |>
dplyr::group_by(lens_model, focal_length) |>
dplyr::summarise(n = dplyr::n()))

## End(Not run)

ISO Plot

Description

ISO Plot

Usage

p_iso(data, bg = "grey", theme = p_theme())

Arguments

data

a data.frame (see details).

bg

a background color.

theme

an optional theme function.

Details

data expects the following columns:

  • lens_model: character, the name of the lens

  • iso_speed: numeric, the ISO speed

  • n: the number of images.

Value

a 'ggplot' object.

Examples

## Not run: 
p_iso(data.frame(lens_model = "foo", iso_speed = 100, n = 3))

## End(Not run)

Lens Plot

Description

Raw images per lens type.

Usage

p_lens(data, fg = "#000", bg = "grey", theme = p_theme())

Arguments

data

a data.frame (see details).

fg

a foreground color.

bg

a background color.

theme

an optional theme function.

Details

data expects the following columns:

  • lens_model: a character string, the name of the lens

  • n: numeric, the number of images for this lens

Value

a 'ggplot' object.

See Also

p_theme()


Orientation Plot

Description

Distribution over landscape and portrait.

Usage

p_orientation(nl, np, fg = "black", bg = "grey", theme = p_theme())

Arguments

nl

a numeric, the number of landscape.

np

a numeric, the number of portraits.

fg

a foreground color.

bg

a background color.

theme

an optional theme function.

Value

a 'ggplot' object.

See Also

p_theme()

Examples

p_orientation(nl = 42, np = 112)

Overview Plot

Description

Overview Plot

Usage

p_overview(metadata)

Arguments

metadata

a data.frame (see details).

Details

metadata expects an output from the scan() function.

Value

a ggplot object.

See Also

scan()

Examples

## Not run: 
viz(scan(path = "."))

## End(Not run)

Shutter Speed Plot

Description

Shutter Speed Plot

Usage

p_shutter_speed(data, fg = "grey", bg = "grey", theme = p_theme())

Arguments

data

a data.frame (see details).

fg

a foreground color.

bg

a background color.

theme

an optional theme function.

Details

data expects the following columns:

  • lens_model: character, the name of the lens

  • exposure_time: character, the aperture value

  • n: the number of images.

Value

a 'ggplot' object.

Examples

## Not run: 
p_shutter_speed(data)

## End(Not run)

Default Theme

Description

Default Theme

Usage

p_theme()

Details

The function is used as a default theme for the plots, which can be replaced by a custom one.

Value

a 'ggplot' theme.

Examples

p_theme()

Sequence of Bytes

Description

Sequence of Bytes

Usage

raw_bytes(x, offset = 0, n = 1)

Arguments

x

a vector of raw bytes.

offset

an integer, to indicate the lower limit of the sequence.

n

an integer, to indicate the length of the sequence.

Details

Note that offset = 0 (default) is the index of the first element of the list.

Value

a vector of raw bytes.

Examples

## Not run: 
# get a sequence of 4 bytes at offset 294
raw_bytes(x, offset = 294, n = 4)

## End(Not run)

Read CR2 File

Description

Read CR2 File

Usage

read_cr2(
  file,
  image = FALSE,
  mapping_exif = mapping_exif,
  mapping_canon = mapping_canon
)

Arguments

file

the file to read (including its path).

image

a logical whether the images should be loaded or not (default FALSE).

mapping_exif

a data.frame of the EXIF tag mapping.

mapping_canon

a data.frame of the Canon tag mapping.

Value

a list.

Examples

## Not run: 
read_cr2(file = "C:/download/example.CR2")

## End(Not run)

Scan Folder

Description

Scan Folder

Usage

scan(path)

Arguments

path

the path to scan.

Value

a data.frame of the metadata.

Examples

## Not run: 
report <- scan(path = ".")

## End(Not run)

Tag Id

Description

Tag Id

Usage

tag_id(mapping, x)

Arguments

mapping

a data.frame for the mapping.

x

a character string, the name of the key.

Value

a character string.

Examples

## Not run: 
tag_id(mapping_exif, "ImageWidth")

## End(Not run)

Convert

Description

Convert

Usage

to_num(x)

Arguments

x

a character vector.

Value

a vector.

Examples

to_num("ffff")