Skip to content

Profiling a folder of images

Before images feed a model or a report, check their sizes, exposure, blur, camera metadata and duplicates. Learn what each number measures and where it misleads.

Applied ~10 min8 steps

What runs in CodeSplash

You will be able to

  • Turn a folder of images into a dataset of file paths and profile it
  • Read brightness, sharpness and the duplicate groups, and know their limits
  • Spot personal data in photo metadata
01

A folder becomes a table

Read

Images don't live in a table, so the app makes one. In Discover → Images, Choose a folder… lists every PNG, JPEG and TIFF as one row: its path, file name and subfolder. The images stay where they are.

The profile then opens each file, measures it, and reports one card for the whole collection. The app decodes TIFF files (scans, microscope and lab images) once for it, so Python and R measure the same pixels. Pictures are measured the way they're stored, not turned by their orientation tag.

02

Make a guess

Predict

Predict first

A test folder lists 26 rows, including a damaged PNG, a text file, a missing file and an empty path. How many images will be read?

Make your guess between 0 and 26 images, then reveal.

Reveal

It reads 22; the rest are listed as unreadable, unsupported or missing. The card always says what it left out.

03

Exposure and blur

Explore
Image brightness and sharpnessWhich images are too dark, washed out, blurry or duplicated?
View data
brightnesssharpnessflagfile
0.0600120.30DarkIMG_1000.jpg
0.08003,651DarkIMG_1001.jpg
0.10003723.60DarkIMG_1002.jpg
0.1200173.60DarkIMG_1003.jpg
0.9000793.30BrightIMG_1004.jpg
0.92005419.30BrightIMG_1005.jpg
0.9400343.60BrightIMG_1006.jpg
0.813015BlurryIMG_1007.jpg
0.524027BlurryIMG_1008.jpg
0.624039BlurryIMG_1009.jpg
0.747051BlurryIMG_1010.jpg
0.693063BlurryIMG_1011.jpg
0.5050432.40OKIMG_1012.jpg
0.3590617.80OKIMG_1013.jpg
0.4440409OKIMG_1014.jpg
0.3930213.50OKIMG_1015.jpg
0.76401,310OKIMG_1016.jpg
0.4250672OKIMG_1017.jpg
0.4200106OKIMG_1018.jpg
0.9310143.70BrightIMG_1019.jpg
0.1310704.70DarkIMG_1020.jpg
0.5020842.40OKIMG_1021.jpg
0.5370289.60OKIMG_1022.jpg
0.6590375.30OKIMG_1023.jpg
0.49101145.60OKIMG_1024.jpg
0.79601107.90OKIMG_1025.jpg
0.1070494.20DarkIMG_1026.jpg
0.7020453.20OKIMG_1027.jpg
0.546011768.20OKIMG_1028.jpg
0.64002192.50OKIMG_1029.jpg
0.4640420.10OKIMG_1030.jpg
0.7040226.50OKIMG_1031.jpg
0.572031.600BlurryIMG_1032.jpg
0.3100120.80OKIMG_1033.jpg
0.6090408.90OKIMG_1034.jpg
0.44601105.60OKIMG_1035.jpg
0.4750137.40OKIMG_1036.jpg
0.8010891.20OKIMG_1037.jpg
0.6110173.90OKIMG_1038.jpg
0.44501016.80OKIMG_1039.jpg
0.57202469.40OKIMG_1040.jpg
0.4830791.70OKIMG_1041.jpg
0.8100119.60OKIMG_1042.jpg
0.4090783.20OKIMG_1043.jpg
0.68301022.10OKIMG_1044.jpg
0.2740569.10OKIMG_1045.jpg
0.35103901.90OKIMG_1046.jpg
0.44401414.90OKIMG_1047.jpg
0.7400598.50OKIMG_1048.jpg
0.405092.200BlurryIMG_1049.jpg
0.4080749.20OKIMG_1050.jpg
0.3620179OKIMG_1051.jpg
0.57101313.10OKIMG_1052.jpg
0.7420330.20OKIMG_1053.jpg
0.75501260.20OKIMG_1054.jpg
0.8030941.80OKIMG_1055.jpg
0.24902,510OKIMG_1056.jpg
0.729093.600DuplicateIMG_1057.jpg
0.6330904.90DuplicateIMG_1058.jpg
0.9450100.90DuplicateIMG_1059.jpg

Brightness is the mean luminance from 0 to 1. Sharpness is the variance of the LaplacianVariance of the LaplacianThe variance of an image's second-derivative (edge) response: sharp images have strong edges and a high value, blurry ones a low value.: strong edges give high values, blur gives low ones.

Plain images (sky, a white backdrop) also score low without being blurred, and small images score lower than large ones. Use the flags to pick files to look at, not to delete.

04

Sizes and shapes

Explore
Image pixel sizesAre the images a consistent size and shape, or a mix of resolutions and orientations?
View data
widthheightformat
256256PNG
512512PNG
1,9201,080PNG
256256PNG
1,5122,016JPEG
1,5001,000JPEG
1,0241,024PNG
960540PNG
3,0002,000JPEG
1,008756JPEG
6,0004,000JPEG
6,0004,000JPEG
512512PNG
1,0241,024PNG
6,0004,000JPEG
6,0004,000JPEG
4,0323,024JPEG
256256PNG
1,5001,000JPEG
256256PNG
256256PNG
1,008756JPEG
256256PNG
1,5122,016JPEG
1,008756JPEG
2,0161,512JPEG
960540PNG
3,0244,032JPEG
3,0244,032JPEG
1,9201,080PNG
1,5122,016JPEG
512512PNG
1,5001,000JPEG
3,0244,032JPEG
256256PNG
4,0323,024JPEG
1,5122,016JPEG
512512PNG
1,5001,000JPEG
960540PNG
3,0002,000JPEG
256256PNG
480270PNG
3,0244,032JPEG
4,0323,024JPEG
1,0241,024PNG
256256PNG
6,0004,000JPEG

Dots on the same dashed ray share a shape. A model that expects one size will resize or crop the rest, so a wide spread here is worth knowing before you train.

05

Duplicates and metadata

Checkpoint

A perceptual hashPerceptual hashA 64-bit fingerprint of an image's coarse brightness pattern; resized, re-saved or lightly edited copies get fingerprints a few bits apart. fingerprints the coarse brightness pattern. Copies that were resized or re-saved stay a few bits apart. In the test folder, 3 images fall into near-duplicate groups.

Check yourself

Why remove or group near-duplicates before splitting images into training and test sets?

Show the answer

Answer: b

Leakage between splits inflates test scores. Grouping near-duplicates keeps each group on one side of the split.

06

Read the card

In the app
Image collection profile (size, color, sharpness, duplicates)Recorded · Python and R agreeRecorded 2026-11-25 · 41 values compared
R

22 images: median 62 × 48 px; 1 dark, 1 bright, 2 blurry, 3 in near-duplicate groups.

Images read
22
Mean brightness
0.5090
Median sharpness
697.19
In duplicate groups
3

Plots

Brightness and sharpnessWhich images are too dark, washed out, blurry or duplicated?
View data
Brightness (0–1)FlagFileSharpness (variance of the Laplacian)
0.5459OKgradient_a.png111.35
0.5459Duplicategradient_a_copy.png111.35
0.5458Duplicategradient_a_near.png138.60
0.3877OKgradient_b.png111.66
0.5002OKstripes_fine.png22408.52
0.5002OKstripes_blurred.png427.86
0.5964OKstripes_wide.png4403.90
0.5294OKchecker.png35891.72
0.5096OKchecker_gray.png27468.42
0.2080OKchecker_alpha.png966.52
0.2885Blurrypalette.png73.680
0.0469Darkdark.png73.171
0.9604Brightbright.png73.887
0.5020Blurryflat_mid.png0
0.5971OKportrait.png201.51
0.5170OKwide_banner.png2909.27
0.5925OKphoto_a.jpg1481.37
0.5011OKphoto_b.jpg8914.04
0.4901OKphoto_c.jpg10461.76
0.8435OKplain.jpg230.68
0.4903OKgray.jpg18698.44
0.5003OKstripes_fine_copy.jpg22509.03
Pixel sizesAre the images a consistent size and shape, or a mix of resolutions and orientations?
View data
FormatHeight (px)FileWidth (px)
PNG48gradient_a.png64
PNG48gradient_a_copy.png64
PNG48gradient_a_near.png64
PNG40gradient_b.png80
PNG64stripes_fine.png64
PNG64stripes_blurred.png64
PNG50stripes_wide.png90
PNG60checker.png60
PNG32checker_gray.png48
PNG40checker_alpha.png40
PNG36palette.png36
PNG40dark.png60
PNG40bright.png60
PNG30flat_mid.png30
PNG90portrait.png40
PNG20wide_banner.png120
JPEG48photo_a.jpg64
JPEG56photo_b.jpg56
JPEG48photo_c.jpg72
JPEG40plain.jpg40
JPEG48gray.jpg48
JPEG64stripes_fine_copy.jpg64
Images by similarity (classic features)Which rows group together, and how well separated are the groups?
View data
FlagFilePC 1PC 2
OKgradient_a.png0.70912.310
Duplicategradient_a_copy.png0.70912.310
Duplicategradient_a_near.png0.70962.295
OKgradient_b.png−2.8340.6196
OKstripes_fine.png−0.0566−1.913
OKstripes_blurred.png−0.1064−1.341
OKstripes_wide.png1.9540.8558
OKchecker.png0.6090−1.846
OKchecker_gray.png0.1656−1.966
OKchecker_alpha.png−6.8330.3521
Blurrypalette.png−5.2692.574
Darkdark.png−10.389−1.554
Brightbright.png10.204−0.4908
Blurryflat_mid.png−0.1527−1.524
OKportrait.png2.2442.898
OKwide_banner.png−0.33540.6315
OKphoto_a.jpg1.7661.773
OKphoto_b.jpg−0.2190−0.4322
OKphoto_c.jpg−0.2570−0.5075
OKplain.jpg7.662−1.198
OKgray.jpg−0.2377−1.765
OKstripes_fine_copy.jpg−0.0436−2.080

Assumptions

  • PNG, JPEG and TIFF — 1 listed files are not PNG, JPEG or a readable kind of TIFF.
  • Sharpness depends on size and content — Sharpness is measured at most 512 pixels on the long side; plain images score low without being blurred.
  • Personal data in metadata — 1 images carry GPS location data (coordinates are not read).

Flagged images

FileFlagBrightnessSharpnessDuplicate group
gradient_a_copy.pngDuplicate0.5459111.351
gradient_a_near.pngDuplicate0.5458138.601
palette.pngBlurry0.288573.6800
dark.pngDark0.046973.1710
bright.pngBright0.960473.8870
flat_mid.pngBlurry0.502000

Cameras (EXIF)

Make and modelImages
Fixturecam FX-1001
Fixturecam FX-2001
Othercam O-11
  • 1 rows have no path and are left out.
  • 1 rows point to files that do not exist and are left out.
  • 1 rows are not PNG, JPEG or a readable kind of TIFF and are left out.
  • 1 rows could not be decoded and are left out.
The exact R script · R R version 4.5.1 (2025-06-13)
# Image collection profile (size, color, sharpness, duplicates)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method describe.images 1.1.0 · spec bcdfced43aa2ed60
# Dataset: ml_images (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
library(codesplashr)

# %% Images listed in the path column
PATH <- "path"
LABEL <- NULL
FOLDER <- path.expand("")
DATA_DIR <- dirname(normalizePath("tests/parity/fixtures/ml_images.parquet", mustWork = FALSE))
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/ml_images.parquet", col_select = c(PATH, LABEL)))
# %% Media files (image column path)
# In the app the files were decoded once into float32 arrays (media.json in the run folder). Elsewhere they are
# decoded here the same way: PNG and WAV give the app's values; JPEG, MP3 and other lossy files can differ slightly.
media <- cs_media_setup(jsonlite::fromJSON("{\"ids_column\":\"media_id\",\"kind\":\"image\",\"path_column\":\"path\",\"role\":\"image\",\"transform\":{\"filter\":\"triangle\",\"fit\":\"original\",\"formats\":[\"tiff\"],\"mode\":\"rgb\",\"normalize\":\"none\",\"orientation\":\"stored\",\"size\":[224,224]}}", simplifyVector = FALSE), "target/academy-parity/run-8142/describe.images/folder_defaults/out-r", df,
                        "tests/parity/fixtures/ml_images.parquet")
media_ids <- cs_media_ids(media, df)
MAX_SIDE <- 512
warnings <- list()
status <- character(0); info <- list(); feats <- list(); hashes <- list()
nz <- function(x) !is.null(x) && !is.na(x) && nzchar(x)
for (i in seq_len(nrow(df))) {
  path <- cs_img_resolve(as.character(df[[PATH]][i]), FOLDER, DATA_DIR)
  if (is.na(path)) { status <- c(status, "no path"); info[[i]] <- list(row = i - 1L); next }
  r <- cs_img_read(path)
  if (r$status == "unsupported" && cs_img_is_tiff(path))  # TIFF: decoded by the host
    r <- cs_img_tiff_read(path, r, media, if (is.null(media_ids)) NA_character_ else media_ids[i])
  status <- c(status, r$status)
  rec <- list(row = i - 1L, path = path, file = basename(path), format = r$format, bytes = r$bytes, md5 = r$md5)
  if (r$status == "ok") {
    small <- cs_img_fit(r$rgb, MAX_SIDE)
    m <- cs_img_measures(small)
    h <- cs_img_phash(cs_img_luma(small))
    rec <- c(rec, list(width = r$width, height = r$height, alpha = r$alpha, phash = cs_img_hex(h)), m,
             if (identical(r$format, "TIFF")) cs_img_tiff_exif(path) else cs_img_exif(path))
    feats[[length(feats) + 1]] <- c(m$brightness, m$contrast, m$mean_r, m$mean_g, m$mean_b, m$colourfulness, m$saturation,
                                    if (is.nan(m$sharpness)) NA else log1p(m$sharpness), m$entropy, cs_img_thumb(small))
    hashes[[length(hashes) + 1]] <- h
  }
  info[[i]] <- rec
}
ok <- which(status == "ok")
if (!length(ok)) {
  if (!length(status)) cs_error("CS_E_NO_ROWS")
  if (all(status == "no path")) cs_error("CS_E_ALL_MISSING", column = PATH)
  # None of the listed files could be read (missing, not PNG, JPEG or TIFF, or not decodable).
  cs_error("CS_E_INVALID_VALUES", column = PATH, requirement = "a PNG, JPEG or TIFF file that exists",
           count = sum(status != "no path"))
}
for (pair in list(c("no path", "have no path"), c("missing", "point to files that do not exist"), c("unsupported", "are not PNG, JPEG or a readable kind of TIFF"), c("unreadable", "could not be decoded"))) {
  k <- sum(status == pair[1])
  if (k) warnings <- c(warnings, sprintf("%d rows %s and are left out.", k, pair[2]))
}
img <- info[ok]

# %% Duplicates: perceptual-hash groups and identical files
DUP <- 6
groups <- cs_img_dup_groups(hashes, DUP)
md5s <- vapply(img, function(r) r$md5, "")
exact <- duplicated(md5s)
first_in_group <- vapply(seq_along(groups), function(j) groups[j] > 0 && match(groups[j], groups) == j, TRUE)

# %% Map: PCA of the classic features
F <- do.call(rbind, feats)
for (c in seq_len(ncol(F))) F[is.na(F[, c]), c] <- mean(F[, c], na.rm = TRUE)
EMBED_LABEL <- "Classic features"
mp <- if (nrow(F) >= 2) cs_img_classic_map(F) else list(Y = matrix(0, nrow(F), 2), shares = c(NaN, NaN))
Y <- mp$Y

# %% Flags
DARK <- 0.15; BRIGHT <- 0.85; BLUR <- 100
flags <- vapply(seq_along(img), function(j) {
  r <- img[[j]]
  if (exact[j] || (groups[j] > 0 && !first_in_group[j])) "Duplicate"
  else if (r$brightness < DARK) "Dark"
  else if (r$brightness > BRIGHT) "Bright"
  else if (!is.nan(r$sharpness) && r$sharpness < BLUR) "Blurry" # after exposure: very dark or bright frames have little detail anyway
  else "OK"
}, "")
for (j in seq_along(img)) img[[j]] <- c(img[[j]], list(dup_group = groups[j], exact_duplicate = exact[j], flag = flags[j], map_x = Y[j, 1], map_y = Y[j, 2]))

# %% Artifacts
out <- cs_ml_out_dir("target/academy-parity/run-8142/describe.images/folder_defaults/out-r")
get <- function(field, type) {
  v <- lapply(img, function(r) if (is.null(r[[field]])) NA else r[[field]])
  switch(type, chr = vapply(v, function(x) if (is.na(x)) NA_character_ else as.character(x), ""),
         num = vapply(v, function(x) as.numeric(x), 0), int = vapply(v, function(x) as.integer(x), 0L),
         lgl = vapply(v, function(x) as.logical(x), TRUE))
}
art <- data.frame(row = get("row", "int"), path = get("path", "chr"), file = get("file", "chr"), format = get("format", "chr"),
                  bytes = get("bytes", "num"), md5 = get("md5", "chr"), width = get("width", "int"), height = get("height", "int"),
                  alpha = get("alpha", "lgl"), stringsAsFactors = FALSE)
for (f in c("brightness", "contrast", "mean_r", "mean_g", "mean_b", "colourfulness", "saturation", "sharpness", "entropy", "clipped_dark", "clipped_bright")) art[[f]] <- get(f, "num")
art$phash <- get("phash", "chr"); art$dup_group <- get("dup_group", "int"); art$exact_duplicate <- get("exact_duplicate", "lgl"); art$flag <- get("flag", "chr")
art$make <- get("make", "chr"); art$model <- get("model", "chr"); art$datetime <- get("datetime", "chr")
art$orientation <- get("orientation", "int"); art$exposure <- get("exposure", "num"); art$fnumber <- get("fnumber", "num")
art$iso <- get("iso", "int"); art$focal <- get("focal", "num"); art$gps <- get("gps", "lgl"); art$map_x <- get("map_x", "num"); art$map_y <- get("map_y", "num")
nanoparquet::write_parquet(art, file.path(out, "images.parquet"))

# %% Result
W <- as.numeric(art$width); H <- as.numeric(art$height); B <- art$brightness; S <- art$sharpness
values <- list(
  n_rows = nrow(df), n_images = length(img), n_no_path = sum(status == "no path"), n_missing = sum(status == "missing"),
  n_unsupported = sum(status == "unsupported"), n_unreadable = sum(status == "unreadable"),
  n_png = sum(art$format == "PNG"), n_jpeg = sum(art$format == "JPEG"), n_alpha = sum(art$alpha), bytes_total = sum(art$bytes),
  width_min = min(W), width_median = stats::median(W), width_max = max(W),
  height_min = min(H), height_median = stats::median(H), height_max = max(H),
  megapixels_median = stats::median(W * H) / 1e6, aspect_median = stats::median(W / H),
  share_portrait = mean(H > W), n_sizes = nrow(unique(data.frame(W, H))),
  brightness_mean = mean(B), brightness_sd = if (length(B) > 1) stats::sd(B) else NULL,
  contrast_mean = mean(art$contrast), colourfulness_mean = mean(art$colourfulness), saturation_mean = mean(art$saturation),
  sharpness_median = if (any(is.finite(S))) stats::median(S[is.finite(S)]) else NULL,
  entropy_mean = mean(art$entropy),
  n_dark = sum(flags == "Dark"), n_bright = sum(flags == "Bright"), n_blurry = sum(flags == "Blurry"),
  n_exif = sum(vapply(img, function(r) nz(r$make) || nz(r$model) || nz(r$datetime), TRUE)),
  n_gps = sum(vapply(img, function(r) isTRUE(r$gps), TRUE)),
  n_dup_groups = if (length(groups)) max(groups) else 0L, n_in_dup_groups = sum(groups > 0), n_exact_dups = sum(exact),
  map_share_1 = mp$shares[1], map_share_2 = mp$shares[2], embedding = EMBED_LABEL
)
n_tiff <- sum(art$format == "TIFF", na.rm = TRUE)
if (n_tiff > 0) values$n_tiff <- n_tiff  # only when TIFF files were read, so results without them keep their keys
cam_names <- vapply(img, function(r) {
  parts <- c(if (nz(r$make)) r$make, if (nz(r$model)) r$model)
  if (length(parts)) paste(parts, collapse = " ") else NA_character_
}, "")
cams <- table(cam_names[!is.na(cam_names)])
if (length(cams)) cams <- cams[order(names(cams), method = "radix")]  # no camera data: an empty table has no names
for (key in names(cams)) values[[sprintf("camera[%s]", key)]] <- as.integer(cams[[key]])
assumptions <- list(
  list(key = "formats", label = "PNG, JPEG and TIFF", status = if (values$n_unsupported) "warn" else "pass",
       detail = if (values$n_unsupported) sprintf("%d listed files are not PNG, JPEG or a readable kind of TIFF.", values$n_unsupported) else "Every readable file is PNG, JPEG or TIFF."),
  list(key = "blur_scale", label = "Sharpness depends on size and content", status = "info",
       detail = sprintf("Sharpness is measured at most %d pixels on the long side; plain images score low without being blurred.", MAX_SIDE)),
  list(key = "personal_data", label = "Personal data in metadata", status = if (values$n_gps) "warn" else "pass",
       detail = if (values$n_gps) sprintf("%d images carry GPS location data (coordinates are not read).", values$n_gps) else "No image carries GPS data.")
)
flagged <- utils::head(which(flags != "OK"), 50)
tables <- list(list(
  key = "flagged", title = "Flagged images",
  columns = list(list(key = "file", label = "File"), list(key = "flag", label = "Flag"), list(key = "brightness", label = "Brightness", type = "number"),
                 list(key = "sharpness", label = "Sharpness", type = "number"), list(key = "dup_group", label = "Duplicate group", type = "integer")),
  rows = lapply(flagged, function(j) list(file = art$file[j], flag = flags[j], brightness = art$brightness[j], sharpness = art$sharpness[j], dup_group = art$dup_group[j]))
))
if (length(cams)) tables[[2]] <- list(key = "cameras", title = "Cameras (EXIF)",
  columns = list(list(key = "camera", label = "Make and model"), list(key = "images", label = "Images", type = "integer")),
  rows = lapply(names(cams), function(k) list(camera = k, images = as.integer(cams[[k]]))))
FLAG_LEVELS <- c("OK", "Dark", "Bright", "Blurry", "Duplicate")
if (!is.null(LABEL)) {
  lab <- df[[LABEL]][art$row + 1L]
  groups_col <- ifelse(is.na(lab), "(missing)", as.character(lab)); group_title <- LABEL
} else {
  groups_col <- flags; group_title <- "Flag"
}
charts <- list(
  cs_chart("quality", "image-quality", "Brightness and sharpness", list(
    brightness = cs_col("Brightness (0–1)", B, "numeric"),
    sharpness = cs_col("Sharpness (variance of the Laplacian)", ifelse(is.nan(S), 0, S), "numeric"),
    flag = cs_col("Flag", flags, "categorical", FLAG_LEVELS),
    label = cs_col("File", art$file, "categorical")
  ), controls = list(dark = DARK, bright = BRIGHT, blur = BLUR)),
  cs_chart("sizes", "image-sizes", "Pixel sizes", list(
    width = cs_col("Width (px)", W, "numeric"), height = cs_col("Height (px)", H, "numeric"),
    group = cs_col("Format", art$format, "categorical"), label = cs_col("File", art$file, "categorical")
  )),
  cs_chart("map", "cluster-scatter", sprintf("Images by similarity (%s)", tolower(EMBED_LABEL)), list(
    x = cs_col("PC 1", Y[, 1], "numeric"), y = cs_col("PC 2", Y[, 2], "numeric"),
    cluster = cs_col(group_title, groups_col, "categorical"), label = cs_col("File", art$file, "categorical")
  ))
)
cs_publish(list(
  title = "Image collection profile (size, color, sharpness, duplicates)",
  engine = cs_engine_info("png", "jpeg", "codesplashr", "nanoparquet"),
  n = length(img),
  summary = sprintf("%d images: median %d × %d px; %d dark, %d bright, %d blurry, %d in near-duplicate groups.",
                    length(img), as.integer(values$width_median), as.integer(values$height_median), values$n_dark, values$n_bright, values$n_blurry, values$n_in_dup_groups),
  statistics = list(
    list(key = "n_images", label = "Images read", value = length(img)),
    list(key = "brightness_mean", label = "Mean brightness", value = values$brightness_mean),
    list(key = "sharpness_median", label = "Median sharpness", value = values$sharpness_median),
    list(key = "n_in_dup_groups", label = "In duplicate groups", value = values$n_in_dup_groups)
  ),
  tables = tables,
  assumptions = assumptions,
  charts = charts,
  values = values,
  warnings = warnings,
  artifacts = list(list(key = "images", path = file.path(out, "images.parquet"), format = "parquet"))
))
Python

22 images: median 62 × 48 px; 1 dark, 1 bright, 2 blurry, 3 in near-duplicate groups.

Images read
22
Mean brightness
0.5090
Median sharpness
697.19
In duplicate groups
3

To keep this page light, the plots are shown once, under the R tab.

Assumptions

  • PNG, JPEG and TIFF — 1 listed files are not PNG, JPEG or a readable kind of TIFF.
  • Sharpness depends on size and content — Sharpness is measured at most 512 pixels on the long side; plain images score low without being blurred.
  • Personal data in metadata — 1 images carry GPS location data (coordinates are not read).

Flagged images

FileFlagBrightnessSharpnessDuplicate group
gradient_a_copy.pngDuplicate0.5459111.351
gradient_a_near.pngDuplicate0.5458138.601
palette.pngBlurry0.288573.6800
dark.pngDark0.046973.1710
bright.pngBright0.960473.8870
flat_mid.pngBlurry0.502000

Cameras (EXIF)

Make and modelImages
Fixturecam FX-1001
Fixturecam FX-2001
Othercam O-11
  • 1 rows have no path and are left out.
  • 1 rows point to files that do not exist and are left out.
  • 1 rows are not PNG, JPEG or a readable kind of TIFF and are left out.
  • 1 rows could not be decoded and are left out.
The exact Python script · Python Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Image collection profile (size, color, sharpness, duplicates)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method describe.images 1.1.0 · spec bcdfced43aa2ed60
# Dataset: ml_images (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
import os

import numpy as np
import pandas as pd

import codesplash as cs
from codesplash import ml as csml
from codesplash.images import features as fx
from codesplash.images import tiff as fxt

# %% Images listed in the path column
PATH = "path"
LABEL = None
FOLDER = os.path.expanduser("")
DATA_DIR = os.path.dirname(os.path.abspath("tests/parity/fixtures/ml_images.parquet"))
df = pd.read_parquet("tests/parity/fixtures/ml_images.parquet", columns=[PATH] if LABEL is None else [PATH, LABEL])
# %% Media files (image column path)
# In the app the files were decoded once into float32 arrays (media.json in the run folder). Elsewhere they are
# decoded here the same way: PNG and WAV give the app's values; JPEG, MP3 and other lossy files can differ slightly.
import json as _media_json
from codesplash import media as cs_media
media = cs_media.setup(_media_json.loads("{\"ids_column\":\"media_id\",\"kind\":\"image\",\"path_column\":\"path\",\"role\":\"image\",\"transform\":{\"filter\":\"triangle\",\"fit\":\"original\",\"formats\":[\"tiff\"],\"mode\":\"rgb\",\"normalize\":\"none\",\"orientation\":\"stored\",\"size\":[224,224]}}"), "target/academy-parity/run-8142/describe.images/folder_defaults/out-python", df, "tests/parity/fixtures/ml_images.parquet")
media_ids = cs_media.ids_of(media, df)
MAX_SIDE = 512
warnings = []
status, info, feats, hashes, thumbs, rgbs = [], [], [], [], [], []
for i, p in enumerate(df[PATH].tolist()):
    path = fx.resolve(p, FOLDER, DATA_DIR)
    if path is None:
        status.append("no path")
        info.append({"row": i, "path": None})
        continue
    r = fx.read(path)
    if r["status"] == "unsupported" and fxt.is_tiff(path):
        r = fxt.read(path, r, media, media_ids[i] if media_ids else None)  # TIFF: decoded by the host
    status.append(r["status"])
    rec = {"row": i, "path": path, "file": os.path.basename(path), "format": r.get("format"), "bytes": r.get("bytes"), "md5": r.get("md5")}
    if r["status"] == "ok":
        small = fx.fit(r["rgb"], MAX_SIDE)
        m = fx.measures(small)
        h = fx.phash(fx.luma(small))
        rec.update(width=r["width"], height=r["height"], alpha=r["alpha"], phash=fx.hex_bits(h), **m,
                   **(fxt.exif(path) if r["format"] == "TIFF" else fx.exif(path)))
        feats.append([m["brightness"], m["contrast"], m["mean_r"], m["mean_g"], m["mean_b"], m["colourfulness"], m["saturation"],
                      np.log1p(m["sharpness"]) if m["sharpness"] == m["sharpness"] else np.nan, m["entropy"], *fx.thumb(small)])
        hashes.append(h)
        rgbs.append(r["rgb"] if False else None)
    info.append(rec)
ok = [k for k, s in enumerate(status) if s == "ok"]
if not ok:
    if not status:
        cs.cs_error("CS_E_NO_ROWS")
    if all(s == "no path" for s in status):
        cs.cs_error("CS_E_ALL_MISSING", column=PATH)
    # None of the listed files could be read (missing, not PNG, JPEG or TIFF, or not decodable).
    cs.cs_error("CS_E_INVALID_VALUES", column=PATH, requirement="a PNG, JPEG or TIFF file that exists",
                count=sum(1 for s in status if s != "no path"))
for s, what in (("no path", "have no path"), ("missing", "point to files that do not exist"), ("unsupported", "are not PNG, JPEG or a readable kind of TIFF"), ("unreadable", "could not be decoded")):
    k = status.count(s)
    if k:
        warnings.append(f"{k} rows {what} and are left out.")
img = [info[k] for k in ok]

# %% Duplicates: perceptual-hash groups and identical files
DUP = 6
groups = fx.dup_groups(hashes, DUP)
seen_md5, exact = set(), []
for rec in img:
    exact.append(rec["md5"] in seen_md5)
    seen_md5.add(rec["md5"])
first_in_group = {}
for j, g in enumerate(groups):
    if g and g not in first_in_group:
        first_in_group[g] = j

# %% Map: PCA of the classic features
F = np.array(feats, dtype=float)
col_mean = np.nanmean(F, axis=0)
F = np.where(np.isnan(F), col_mean, F)
EMBED_LABEL = "Classic features"
Y, map_shares = fx.classic_map(F) if len(F) >= 2 else (np.zeros((len(F), 2)), [float("nan"), float("nan")])

# %% Flags
DARK, BRIGHT, BLUR = 0.15, 0.85, 100
flags = []
for j, rec in enumerate(img):
    if exact[j] or (groups[j] and first_in_group[groups[j]] != j):
        f = "Duplicate"
    elif rec["brightness"] < DARK:
        f = "Dark"
    elif rec["brightness"] > BRIGHT:
        f = "Bright"
    elif rec["sharpness"] == rec["sharpness"] and rec["sharpness"] < BLUR:
        f = "Blurry"  # after exposure: very dark or bright frames have little detail anyway
    else:
        f = "OK"
    flags.append(f)
    rec.update(dup_group=int(groups[j]), exact_duplicate=bool(exact[j]), flag=f, map_x=float(Y[j, 0]), map_y=float(Y[j, 1]))

# %% Artifacts
out = csml.out_dir("target/academy-parity/run-8142/describe.images/folder_defaults/out-python")
cols = ["row", "path", "file", "format", "bytes", "md5", "width", "height", "alpha", "brightness", "contrast", "mean_r", "mean_g", "mean_b",
        "colourfulness", "saturation", "sharpness", "entropy", "clipped_dark", "clipped_bright", "phash", "dup_group", "exact_duplicate", "flag",
        "make", "model", "datetime", "orientation", "exposure", "fnumber", "iso", "focal", "gps", "map_x", "map_y"]
art = pd.DataFrame([{c: rec.get(c) for c in cols} for rec in img], columns=cols)
for c in ("make", "model", "datetime", "phash", "flag", "format", "file", "path", "md5"):
    art[c] = art[c].astype("string")
for c in ("orientation", "iso"):
    art[c] = pd.array([None if pd.isna(v) else int(v) for v in art[c]], dtype="Int64")
for c in ("exposure", "fnumber", "focal"):
    art[c] = pd.to_numeric(art[c], errors="coerce").astype("float64")
art["gps"] = art["gps"].astype("boolean")
art.to_parquet(os.path.join(out, "images.parquet"), index=False)

# %% Result
W = np.array([r["width"] for r in img], dtype=float)
H = np.array([r["height"] for r in img], dtype=float)
B = np.array([r["brightness"] for r in img])
S = np.array([r["sharpness"] for r in img])
values = {
    "n_rows": len(df), "n_images": len(img), "n_no_path": status.count("no path"), "n_missing": status.count("missing"),
    "n_unsupported": status.count("unsupported"), "n_unreadable": status.count("unreadable"),
    "n_png": sum(r["format"] == "PNG" for r in img), "n_jpeg": sum(r["format"] == "JPEG" for r in img),
    "n_alpha": sum(bool(r["alpha"]) for r in img), "bytes_total": int(sum(r["bytes"] for r in img)),
    "width_min": float(W.min()), "width_median": float(np.median(W)), "width_max": float(W.max()),
    "height_min": float(H.min()), "height_median": float(np.median(H)), "height_max": float(H.max()),
    "megapixels_median": float(np.median(W * H) / 1e6), "aspect_median": float(np.median(W / H)),
    "share_portrait": float(np.mean(H > W)), "n_sizes": len({(int(w), int(h)) for w, h in zip(W, H)}),
    "brightness_mean": float(B.mean()), "brightness_sd": float(B.std(ddof=1)) if len(B) > 1 else None,
    "contrast_mean": float(np.mean([r["contrast"] for r in img])),
    "colourfulness_mean": float(np.mean([r["colourfulness"] for r in img])),
    "saturation_mean": float(np.mean([r["saturation"] for r in img])),
    "sharpness_median": float(np.nanmedian(S)) if np.isfinite(S).any() else None,
    "entropy_mean": float(np.mean([r["entropy"] for r in img])),
    "n_dark": flags.count("Dark"), "n_bright": flags.count("Bright"), "n_blurry": flags.count("Blurry"),
    "n_exif": sum(1 for r in img if r.get("make") or r.get("model") or r.get("datetime")),
    "n_gps": sum(1 for r in img if r.get("gps")),
    "n_dup_groups": int(groups.max()) if len(groups) else 0, "n_in_dup_groups": int(np.sum(groups > 0)),
    "n_exact_dups": int(sum(exact)),
    "map_share_1": map_shares[0], "map_share_2": map_shares[1], "embedding": EMBED_LABEL,
}
n_tiff = sum(r["format"] == "TIFF" for r in img)
if n_tiff:
    values["n_tiff"] = n_tiff  # only when TIFF files were read, so results without them keep their keys
cams: dict[str, int] = {}
for r in img:
    if r.get("make") or r.get("model"):
        key = " ".join(x for x in (r.get("make"), r.get("model")) if x)
        cams[key] = cams.get(key, 0) + 1
for key, k in sorted(cams.items()):
    values[f"camera[{key}]"] = k
assumptions = [
    {"key": "formats", "label": "PNG, JPEG and TIFF", "status": "warn" if values["n_unsupported"] else "pass",
     "detail": f"{values['n_unsupported']} listed files are not PNG, JPEG or a readable kind of TIFF." if values["n_unsupported"] else "Every readable file is PNG, JPEG or TIFF."},
    {"key": "blur_scale", "label": "Sharpness depends on size and content", "status": "info",
     "detail": f"Sharpness is measured at most {MAX_SIDE} pixels on the long side; plain images score low without being blurred."},
    {"key": "personal_data", "label": "Personal data in metadata", "status": "warn" if values["n_gps"] else "pass",
     "detail": f"{values['n_gps']} images carry GPS location data (coordinates are not read)." if values["n_gps"] else "No image carries GPS data."},
]
flagged = [r for r in img if r["flag"] != "OK"][:50]
tables = [{
    "key": "flagged", "title": "Flagged images",
    "columns": [{"key": "file", "label": "File"}, {"key": "flag", "label": "Flag"}, {"key": "brightness", "label": "Brightness", "type": "number"},
                {"key": "sharpness", "label": "Sharpness", "type": "number"}, {"key": "dup_group", "label": "Duplicate group", "type": "integer"}],
    "rows": [{k: r.get(k) for k in ("file", "flag", "brightness", "sharpness", "dup_group")} for r in flagged],
}]
if cams:
    tables.append({"key": "cameras", "title": "Cameras (EXIF)", "columns": [{"key": "camera", "label": "Make and model"}, {"key": "images", "label": "Images", "type": "integer"}],
                   "rows": [{"camera": key, "images": k} for key, k in sorted(cams.items())]})
FLAG_LEVELS = ["OK", "Dark", "Bright", "Blurry", "Duplicate"]
if LABEL is not None:
    lab = df[LABEL].iloc[[r["row"] for r in img]]
    groups_col = ["(missing)" if pd.isna(v) else str(v) for v in lab]
    group_title = LABEL
else:
    groups_col, group_title = flags, "Flag"
charts = [
    cs.chart("quality", "image-quality", "Brightness and sharpness", {
        "brightness": cs.col("Brightness (0–1)", B, "numeric"),
        "sharpness": cs.col("Sharpness (variance of the Laplacian)", np.nan_to_num(S, nan=0.0), "numeric"),
        "flag": cs.col("Flag", flags, "categorical", FLAG_LEVELS),
        "label": cs.col("File", [r["file"] for r in img], "categorical"),
    }, controls={"dark": DARK, "bright": BRIGHT, "blur": BLUR}),
    cs.chart("sizes", "image-sizes", "Pixel sizes", {
        "width": cs.col("Width (px)", W, "numeric"),
        "height": cs.col("Height (px)", H, "numeric"),
        "group": cs.col("Format", [r["format"] for r in img], "categorical"),
        "label": cs.col("File", [r["file"] for r in img], "categorical"),
    }),
    cs.chart("map", "cluster-scatter", f"Images by similarity ({EMBED_LABEL.lower()})", {
        "x": cs.col("PC 1", Y[:, 0], "numeric"),
        "y": cs.col("PC 2", Y[:, 1], "numeric"),
        "cluster": cs.col(group_title, groups_col, "categorical"),
        "label": cs.col("File", [r["file"] for r in img], "categorical"),
    }),
]
cs.publish({
    "title": "Image collection profile (size, color, sharpness, duplicates)",
    "engine": cs.engine_info("pillow", "numpy", "pandas"),
    "n": len(img),
    "summary": f"{len(img)} images: median {int(values['width_median'])} × {int(values['height_median'])} px; {values['n_dark']} dark, {values['n_bright']} bright, {values['n_blurry']} blurry, {values['n_in_dup_groups']} in near-duplicate groups.",
    "statistics": [
        {"key": "n_images", "label": "Images read", "value": len(img)},
        {"key": "brightness_mean", "label": "Mean brightness", "value": values["brightness_mean"]},
        {"key": "sharpness_median", "label": "Median sharpness", "value": values["sharpness_median"]},
        {"key": "n_in_dup_groups", "label": "In duplicate groups", "value": values["n_in_dup_groups"]},
    ],
    "tables": tables,
    "assumptions": assumptions,
    "charts": charts,
    "values": values,
    "warnings": warnings,
    "artifacts": [{"key": "images", "path": os.path.join(out, "images.parquet"), "format": "parquet"}],
})

EXIFEXIF metadataData a camera stores inside a photo: make, model, date taken, exposure, orientation and sometimes GPS location. gives the camera, the date and sometimes a GPS location. The card counts 1 images with GPS data but never reads the coordinates out.

Check yourself

Some photos carry GPS data. What's the sensible step before you share them?

Show the answer

Answer: b

A location can identify a home or a routine. Removing metadata from shared copies keeps the pictures and drops the personal data.

07

Do it on your own data

In the app

Choose Images in Discover, then Choose a folder…. Open Image collection profile when the dataset appears. A pretrained map (MobileNetV3, about 10 MB, Python only) is optional and asks before downloading.

Python
from codesplash.images import features as fx

r = fx.read("photos/IMG_0001.jpg")
small = fx.fit(r["rgb"], 512)          # area-averaged copy, long side ≤ 512 px
print(fx.measures(small)["sharpness"], fx.hex_bits(fx.phash(fx.luma(small))))
print(fx.exif("photos/IMG_0001.jpg"))  # GPS only as present or absent
R
library(codesplashr)
r <- cs_img_read("photos/IMG_0001.jpg")
small <- cs_img_fit(r$rgb, 512)
cs_img_measures(small)$sharpness
cs_img_hex(cs_img_phash(cs_img_luma(small)))
cs_img_exif("photos/IMG_0001.jpg")
08

Recap

Recap
  • A folder becomes a dataset of file paths; the profile reads PNG, JPEG and TIFF and lists what it skipped.
  • Brightness and sharpness flag files to look at; plain or small images score low without being bad.
  • Group near-duplicates before splitting, and treat photo metadata as personal data.

Concepts in this lesson