| 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 |
Extract the TIFF and Canon headers.
header(x)header(x)
x |
a raw vector. |
The function returns a list with the following elements:
endianness: order in which the bites are written (expecting little endian / II)
magic_number: TIFF signature (expecting 42)
offset_first_ifd: offset to first ifd
cr_marker: raw marker (expecting 'CR+2')
cr_version: raw marker version
offset_ifd_raw: offset to first raw ifd
a list.
## Not run: header(x) ## End(Not run)## Not run: header(x) ## End(Not run)
Image File Directory
ifd(x, offset = 1)ifd(x, offset = 1)
x |
a raw vector. |
offset |
an integer to indicate where the sequence starts. |
The output list contains:
nb_entries: the number of entries
entries: the entries
offset_next_ifd: offset to the next ifd.
a list with the IFD information.
## Not run: ifd(x, offset = 924) ## End(Not run)## Not run: ifd(x, offset = 924) ## End(Not run)
IFD Entry Value or Offset
ifd_entry(ifd, id, raw_vector = NULL, verbose = FALSE)ifd_entry(ifd, id, raw_vector = NULL, verbose = FALSE)
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. |
ifd expects a list as returned by the ifd() function.
a numeric value or a vector with the offset.
## Not run: ifd_entry(ifd, id = "0100") ## End(Not run)## Not run: ifd_entry(ifd, id = "0100") ## End(Not run)
Extract most frequent combination.
most_frequent(data)most_frequent(data)
data |
a data.frame (output of |
The function computes the most frequent combination over: camera, orientation, exposure_time, f_number, iso_speed, lens_model, focal_length
a data.frame.
## Not run: most_frequent(scan(".")) ## End(Not run)## Not run: most_frequent(scan(".")) ## End(Not run)
Order Bytes
order_bytes(x, endian = "II")order_bytes(x, endian = "II")
x |
a vector or data.frame of bytes. |
endian |
the endianess. |
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.
the corresponding hexadecimal vector or data.frame.
## Not run: order_bytes(x, endian = "II") ## End(Not run)## Not run: order_bytes(x, endian = "II") ## End(Not run)
Aperture Plot
p_aperture(data, fg = "grey", bg = "grey", theme = p_theme())p_aperture(data, fg = "grey", bg = "grey", theme = p_theme())
data |
a data.frame (see details). |
fg |
a foreground color. |
bg |
a background color. |
theme |
an optional theme function. |
data expects the following columns:
lens_model: character, the name of the lens
f_number: character, the aperture value
a 'ggplot' object.
## Not run: p_aperture(data) ## End(Not run)## Not run: p_aperture(data) ## End(Not run)
Camera Plot
p_camera(data, fg = NA, bg = "grey", theme = p_theme())p_camera(data, fg = NA, bg = "grey", theme = p_theme())
data |
a data.frame (see details). |
fg |
a foreground color. |
bg |
a background color. |
theme |
an optional theme function. |
data expects a data.frame with the following columns:
camera: character, the camera name
n: numeric, the number of images for the camera
a 'ggplot' object.
p_camera(data.frame(camera = "Canon EOS 70D", n = 10))p_camera(data.frame(camera = "Canon EOS 70D", n = 10))
Focal Length Plot
p_focal(data, fg = "grey", bg = "grey", theme = p_theme())p_focal(data, fg = "grey", bg = "grey", theme = p_theme())
data |
a data.frame (see details). |
fg |
a foreground color. |
bg |
a background color. |
theme |
an optional theme function. |
data expects the following columns:
lens_model: character, the name of the lens
focal_length: numeric, the focal length
n: the number of images.
a 'ggplot' object.
## Not run: p_focal(data = metadata |> dplyr::group_by(lens_model, focal_length) |> dplyr::summarise(n = dplyr::n())) ## End(Not run)## Not run: p_focal(data = metadata |> dplyr::group_by(lens_model, focal_length) |> dplyr::summarise(n = dplyr::n())) ## End(Not run)
ISO Plot
p_iso(data, bg = "grey", theme = p_theme())p_iso(data, bg = "grey", theme = p_theme())
data |
a data.frame (see details). |
bg |
a background color. |
theme |
an optional theme function. |
data expects the following columns:
lens_model: character, the name of the lens
iso_speed: numeric, the ISO speed
n: the number of images.
a 'ggplot' object.
## Not run: p_iso(data.frame(lens_model = "foo", iso_speed = 100, n = 3)) ## End(Not run)## Not run: p_iso(data.frame(lens_model = "foo", iso_speed = 100, n = 3)) ## End(Not run)
Raw images per lens type.
p_lens(data, fg = "#000", bg = "grey", theme = p_theme())p_lens(data, fg = "#000", bg = "grey", theme = p_theme())
data |
a data.frame (see details). |
fg |
a foreground color. |
bg |
a background color. |
theme |
an optional theme function. |
data expects the following columns:
lens_model: a character string, the name of the lens
n: numeric, the number of images for this lens
a 'ggplot' object.
Distribution over landscape and portrait.
p_orientation(nl, np, fg = "black", bg = "grey", theme = p_theme())p_orientation(nl, np, fg = "black", bg = "grey", theme = p_theme())
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. |
a 'ggplot' object.
p_orientation(nl = 42, np = 112)p_orientation(nl = 42, np = 112)
Overview Plot
p_overview(metadata)p_overview(metadata)
metadata |
a data.frame (see details). |
metadata expects an output from the scan() function.
a ggplot object.
## Not run: viz(scan(path = ".")) ## End(Not run)## Not run: viz(scan(path = ".")) ## End(Not run)
Shutter Speed Plot
p_shutter_speed(data, fg = "grey", bg = "grey", theme = p_theme())p_shutter_speed(data, fg = "grey", bg = "grey", theme = p_theme())
data |
a data.frame (see details). |
fg |
a foreground color. |
bg |
a background color. |
theme |
an optional theme function. |
data expects the following columns:
lens_model: character, the name of the lens
exposure_time: character, the aperture value
n: the number of images.
a 'ggplot' object.
## Not run: p_shutter_speed(data) ## End(Not run)## Not run: p_shutter_speed(data) ## End(Not run)
Default Theme
p_theme()p_theme()
The function is used as a default theme for the plots, which can be replaced by a custom one.
a 'ggplot' theme.
p_theme()p_theme()
Sequence of Bytes
raw_bytes(x, offset = 0, n = 1)raw_bytes(x, offset = 0, n = 1)
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. |
Note that offset = 0 (default) is the index of the first element of the list.
a vector of raw bytes.
## Not run: # get a sequence of 4 bytes at offset 294 raw_bytes(x, offset = 294, n = 4) ## End(Not run)## Not run: # get a sequence of 4 bytes at offset 294 raw_bytes(x, offset = 294, n = 4) ## End(Not run)
Read CR2 File
read_cr2( file, image = FALSE, mapping_exif = mapping_exif, mapping_canon = mapping_canon )read_cr2( file, image = FALSE, mapping_exif = mapping_exif, mapping_canon = mapping_canon )
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. |
a list.
## Not run: read_cr2(file = "C:/download/example.CR2") ## End(Not run)## Not run: read_cr2(file = "C:/download/example.CR2") ## End(Not run)
Scan Folder
scan(path)scan(path)
path |
the path to scan. |
a data.frame of the metadata.
## Not run: report <- scan(path = ".") ## End(Not run)## Not run: report <- scan(path = ".") ## End(Not run)
Tag Id
tag_id(mapping, x)tag_id(mapping, x)
mapping |
a data.frame for the mapping. |
x |
a character string, the name of the key. |
a character string.
## Not run: tag_id(mapping_exif, "ImageWidth") ## End(Not run)## Not run: tag_id(mapping_exif, "ImageWidth") ## End(Not run)
Convert
to_num(x)to_num(x)
x |
a character vector. |
a vector.
to_num("ffff")to_num("ffff")