docling 2.92.0

DocumentConverter and format backends for docling.rs (a Rust port of docling).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
//! Images placed in cells — Excel 365's "Place in Cell" (docling#5015).
//!
//! Such an image is not a drawing: it is a *rich value*. The cell keeps the
//! error value `#VALUE!` as a fallback for readers without rich-data support
//! and refers to the image through its `vm` (value metadata) attribute:
//!
//! ```text
//! <c vm="1"> -> metadata valueMetadata -> futureMetadata XLRICHVALUE
//!            -> rdrichvalue rv -> rdrichvaluestructure "_localImage"
//!            -> richValueRel rel -> image part
//! ```
//!
//! A port of docling's `_rich_value_images` / `_cells_with_rich_values`: only
//! rich values with the `_localImage` structure are images (linked data types
//! and the like are other structures and stay their fallback text); the
//! value's `Text` key is Excel's alternative text, which docling writes as the
//! picture's description.

use std::collections::HashMap;
use std::sync::Arc;

use docling_core::PictureImage;
use roxmltree::Document;

use super::ooxml::{resolve, Package, Relationship};

/// One image placed in a cell: the decoded image (`None` when the part is
/// missing or undecodable — the cell is still a picture, as in docling) and
/// its alternative text.
#[derive(Debug, Clone, PartialEq)]
pub(crate) struct CellImage {
    pub(crate) image: Option<PictureImage>,
    pub(crate) alt_text: Option<String>,
}

/// Where one structure of rich value keeps its images (docling's
/// `_RichImageKind`): the workbook part, the rich value key holding the
/// image's position in that part, the part's entries, and the child of an
/// entry carrying the relationship id (`None`: the entry itself).
struct ImageKind {
    structure: &'static str,
    part: &'static str,
    position_key: &'static str,
    entry: &'static str,
    id_child: Option<&'static str>,
}

/// "Place in Cell" images (docling#5015) and images from the `IMAGE()`
/// function (docling#5271, #1169), the downloaded copy Excel stores in
/// `rdRichValueWebImage.xml`.
const IMAGE_KINDS: [ImageKind; 2] = [
    ImageKind {
        structure: "_localImage",
        part: "richValueRel",
        position_key: "_rvRel:LocalImageIdentifier",
        entry: "rel",
        id_child: None,
    },
    ImageKind {
        structure: "_webimage",
        part: "rdRichValueWebImage",
        position_key: "WebImageIdentifier",
        entry: "webImageSrd",
        id_child: Some("blip"),
    },
];

/// The workbook's images placed in cells, by the 1-based `vm` index a cell
/// refers to them with. Empty unless the workbook relates the three
/// rich-data parts and at least one image part (docling's
/// `_rich_data_parts`: the relationship types are matched by their last
/// segment, whose namespace differs between Excel versions).
pub(crate) fn rich_value_images(
    pkg: &mut Package,
    workbook_rels: &[Relationship],
) -> HashMap<u32, Arc<CellImage>> {
    let part = |name: &str| {
        workbook_rels
            .iter()
            .find(|r| r.rel_type.rsplit('/').next() == Some(name))
            .map(|r| resolve("xl", &r.target))
    };
    let (Some(meta), Some(rv), Some(rvs)) = (
        part("sheetMetadata"),
        part("rdRichValue"),
        part("rdRichValueStructure"),
    ) else {
        return HashMap::new();
    };
    // Each kind's image parts, by position in its part; an entry without an
    // image (a web image without a `blip`) keeps its position.
    let mut targets: HashMap<&'static str, Vec<Option<String>>> = HashMap::new();
    for kind in &IMAGE_KINDS {
        let Some(path) = part(kind.part) else {
            continue;
        };
        let Some(xml) = pkg.read(&path) else {
            continue;
        };
        let dir = path.rsplit_once('/').map(|(d, _)| d).unwrap_or("");
        let rels: HashMap<String, String> = pkg
            .rels_for(&path)
            .into_iter()
            .filter(|r| r.rel_type.ends_with("/image"))
            .map(|r| (r.id, resolve(dir, &r.target)))
            .collect();
        let ids = image_entries(&xml, kind);
        targets.insert(
            kind.structure,
            ids.into_iter()
                .map(|id| id.and_then(|id| rels.get(&id).cloned()))
                .collect(),
        );
    }
    if targets.is_empty() {
        return HashMap::new();
    }
    let (Some(meta_xml), Some(rv_xml), Some(rvs_xml)) =
        (pkg.read(&meta), pkg.read(&rv), pkg.read(&rvs))
    else {
        return HashMap::new();
    };
    let index = parse_rich_values(&meta_xml, &rv_xml, &rvs_xml, &targets);
    // Each image part is decoded once, however many cells show it; one that
    // is missing, oversized or undecodable loses its own data only.
    let mut decoded: HashMap<String, Option<PictureImage>> = HashMap::new();
    let mut out = HashMap::new();
    for (vm, (target, alt_text)) in index {
        let image = decoded
            .entry(target.clone())
            .or_insert_with(|| {
                pkg.read_bytes(&target)
                    .filter(|bytes| decodes(bytes))
                    .and_then(|bytes| super::ooxml::picture_image(&target, bytes))
            })
            .clone();
        out.insert(vm, Arc::new(CellImage { image, alt_text }));
    }
    out
}

/// Whether a cell image decodes in full, within the `image` crate's
/// allocation limits — docling loads it through Pillow, so a truncated
/// image, or one whose header declares more pixels than Pillow's limit,
/// loses its data (docling#5271's isolation tests) while the cell stays a
/// picture. A metafile is kept undecoded, as docling keeps it.
fn decodes(bytes: &[u8]) -> bool {
    super::ooxml::is_metafile(bytes)
        || image::ImageReader::new(std::io::Cursor::new(bytes))
            .with_guessed_format()
            .ok()
            .is_some_and(|r| r.decode().is_ok())
}

/// The relationship id of each entry of an image part, by position (`None`
/// for an entry without one).
fn image_entries(xml: &str, kind: &ImageKind) -> Vec<Option<String>> {
    let Ok(doc) = Document::parse(xml) else {
        return Vec::new();
    };
    children(doc.root_element(), kind.entry)
        .map(|entry| {
            let node = match kind.id_child {
                None => Some(entry),
                Some(child) => children(entry, child).next(),
            }?;
            node.attributes()
                .find(|a| {
                    a.name() == "id"
                        && a.namespace()
                            .is_some_and(|ns| ns.ends_with("/relationships"))
                })
                .map(|a| a.value().to_string())
        })
        .collect()
}

/// The XML half of [`rich_value_images`]: `vm` → (the image's part, its
/// alternative text), `targets` being each image structure's parts by
/// position. Malformed parts yield nothing.
fn parse_rich_values(
    metadata: &str,
    rich_values: &str,
    structures: &str,
    targets: &HashMap<&'static str, Vec<Option<String>>>,
) -> HashMap<u32, (String, Option<String>)> {
    let mut out = HashMap::new();
    let (Ok(meta), Ok(rv), Ok(rvs)) = (
        Document::parse(metadata),
        Document::parse(rich_values),
        Document::parse(structures),
    ) else {
        return out;
    };
    let root = meta.root_element();
    // Metadata types are 1-based in `rc/@t`.
    let Some(rich_type) = children(root, "metadataTypes")
        .flat_map(|n| children(n, "metadataType"))
        .position(|n| n.attribute("name") == Some("XLRICHVALUE"))
        .map(|i| (i + 1).to_string())
    else {
        return out;
    };
    // `futureMetadata[@name='XLRICHVALUE']/bk` → its `rvb/@i`, the rich
    // value index.
    let future: Vec<Option<usize>> = children(root, "futureMetadata")
        .filter(|n| n.attribute("name") == Some("XLRICHVALUE"))
        .flat_map(|n| children(n, "bk"))
        .map(|bk| {
            bk.descendants()
                .find(|d| d.is_element() && d.tag_name().name() == "rvb")
                .and_then(|d| d.attribute("i")?.parse().ok())
        })
        .collect();
    let structs: Vec<(Option<&str>, Vec<Option<&str>>)> = children(rvs.root_element(), "s")
        .map(|s| {
            let keys = children(s, "k").map(|k| k.attribute("n")).collect();
            (s.attribute("t"), keys)
        })
        .collect();
    // Rich value index → (image part, alt text), image structures only.
    let images: HashMap<usize, (String, Option<String>)> = children(rv.root_element(), "rv")
        .enumerate()
        .filter_map(|(index, node)| {
            let s: usize = node.attribute("s")?.parse().ok()?;
            let (kind, keys) = structs.get(s)?;
            let kind = IMAGE_KINDS.iter().find(|k| Some(k.structure) == *kind)?;
            let values: Vec<String> = children(node, "v")
                .map(|v| v.text().unwrap_or("").to_string())
                .collect();
            let field = |key: &str| {
                let at = keys.iter().position(|k| *k == Some(key))?;
                values.get(at)
            };
            let position: usize = field(kind.position_key)?.trim().parse().ok()?;
            let target = targets.get(kind.structure)?.get(position)?.clone()?;
            let alt = field("Text").filter(|t| !t.is_empty()).cloned();
            Some((index, (target, alt)))
        })
        .collect();
    let blocks = children(root, "valueMetadata").flat_map(|n| children(n, "bk"));
    for (vm, bk) in blocks.enumerate() {
        // docling reads the block's (first) `rc` record.
        let Some(rc) = children(bk, "rc").next() else {
            continue;
        };
        if rc.attribute("t") != Some(rich_type.as_str()) {
            continue;
        }
        let Some(Some(rv_index)) = rc
            .attribute("v")
            .and_then(|v| v.parse::<usize>().ok())
            .and_then(|v| future.get(v))
        else {
            continue;
        };
        if let Some(image) = images.get(rv_index) {
            out.insert(vm as u32 + 1, image.clone());
        }
    }
    out
}

/// The element children of `n` named `name` (any namespace).
fn children<'a, 'i>(
    n: roxmltree::Node<'a, 'i>,
    name: &'static str,
) -> impl Iterator<Item = roxmltree::Node<'a, 'i>> {
    n.children()
        .filter(move |c| c.is_element() && c.tag_name().name() == name)
}

/// The `vm` index of every cell of a worksheet that has one, by absolute
/// 0-based `(row, col)` — calamine does not keep the attribute, so the sheet
/// XML is scanned again (docling's `_cells_with_rich_values`, which re-reads
/// it past openpyxl the same way).
pub(crate) fn cells_with_rich_values(sheet_xml: &str) -> HashMap<(u32, u32), u32> {
    let mut out = HashMap::new();
    let tag = cached_regex!(r"<c\s[^>]*>");
    let attr_r = cached_regex!(r#"\br="([A-Z]+)(\d+)""#);
    let attr_vm = cached_regex!(r#"\bvm="(\d+)""#);
    for m in tag.find_iter(sheet_xml) {
        let t = m.as_str();
        let Some(vm) = attr_vm.captures(t).and_then(|c| c[1].parse::<u32>().ok()) else {
            continue;
        };
        let Some(r) = attr_r.captures(t) else {
            continue;
        };
        let col = r[1].bytes().fold(0u32, |acc, b| {
            acc.saturating_mul(26).saturating_add((b - b'A' + 1) as u32)
        });
        let Ok(row) = r[2].parse::<u32>() else {
            continue;
        };
        if row == 0 || col == 0 {
            continue;
        }
        out.insert((row - 1, col - 1), vm);
    }
    out
}

#[cfg(test)]
mod tests {
    use super::*;

    const META: &str = r#"<metadata xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:xlrd="http://schemas.microsoft.com/office/spreadsheetml/2017/richdata"><metadataTypes count="2"><metadataType name="XLDAPR"/><metadataType name="XLRICHVALUE"/></metadataTypes><futureMetadata name="XLRICHVALUE" count="3"><bk><extLst><ext><xlrd:rvb i="0"/></ext></extLst></bk><bk><extLst><ext><xlrd:rvb i="1"/></ext></extLst></bk><bk><extLst><ext><xlrd:rvb i="2"/></ext></extLst></bk></futureMetadata><valueMetadata count="4"><bk><rc t="2" v="0"/></bk><bk><rc t="1" v="1"/></bk><bk><rc t="2" v="1"/></bk><bk><rc t="2" v="2"/></bk></valueMetadata></metadata>"#;
    const RV: &str = r#"<rvData xmlns="http://schemas.microsoft.com/office/spreadsheetml/2017/richdata"><rv s="0"><v>1</v><v>5</v><v>A cat</v></rv><rv s="1"><v>0</v><v>5</v></rv><rv s="2"><v>Seattle</v></rv></rvData>"#;
    const RVS: &str = r#"<rvStructures xmlns="http://schemas.microsoft.com/office/spreadsheetml/2017/richdata"><s t="_localImage"><k n="_rvRel:LocalImageIdentifier" t="i"/><k n="CalcOrigin" t="i"/><k n="Text" t="s"/></s><s t="_localImage"><k n="_rvRel:LocalImageIdentifier" t="i"/><k n="CalcOrigin" t="i"/></s><s t="_linkedEntity"><k n="Name" t="s"/></s></rvStructures>"#;
    const RELS: &str = r#"<richValueRels xmlns="http://schemas.microsoft.com/office/spreadsheetml/2022/richvaluerel" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><rel r:id="rIdA"/><rel r:id="rIdB"/></richValueRels>"#;

    /// The `vm` chain: a block of another metadata type, and a rich value of
    /// a non-image structure (a linked data type), are not images.
    fn targets(entries: Vec<Option<String>>) -> HashMap<&'static str, Vec<Option<String>>> {
        HashMap::from([("_localImage", entries)])
    }

    #[test]
    fn resolves_vm_through_the_rich_value_chain() {
        let ids = image_entries(RELS, &IMAGE_KINDS[0]);
        assert_eq!(ids, [Some("rIdA".to_string()), Some("rIdB".to_string())]);
        let got = parse_rich_values(META, RV, RVS, &targets(ids));
        assert_eq!(got.len(), 2, "{got:?}");
        assert_eq!(got[&1], ("rIdB".to_string(), Some("A cat".to_string())));
        // vm 2 is an `XLDAPR` block; vm 4 is the linked entity.
        assert_eq!(got[&3], ("rIdA".to_string(), None));
    }

    /// docling#5271 (#1169): an `IMAGE()` rich value (`_webimage`) points
    /// into `rdRichValueWebImage.xml` by position; a web image without a
    /// `blip` keeps its position, so the images after it stay aligned, and
    /// its cell keeps `#VALUE!`.
    #[test]
    fn web_images_resolve_by_position_and_skip_blipless_entries() {
        let web = r#"<webImagesSrd xmlns="http://schemas.microsoft.com/office/spreadsheetml/2020/richdatawebimage" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><webImageSrd><address r:id="rIdU1"/><blip r:id="rIdI1"/></webImageSrd><webImageSrd><address r:id="rIdU2"/></webImageSrd><webImageSrd><address r:id="rIdU3"/><blip r:id="rIdI3"/></webImageSrd></webImagesSrd>"#;
        let ids = image_entries(web, &IMAGE_KINDS[1]);
        assert_eq!(
            ids,
            [Some("rIdI1".to_string()), None, Some("rIdI3".to_string())]
        );
        let meta = r#"<metadata xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:xlrd="http://schemas.microsoft.com/office/spreadsheetml/2017/richdata"><metadataTypes><metadataType name="XLRICHVALUE"/></metadataTypes><futureMetadata name="XLRICHVALUE"><bk><extLst><ext><xlrd:rvb i="0"/></ext></extLst></bk><bk><extLst><ext><xlrd:rvb i="1"/></ext></extLst></bk><bk><extLst><ext><xlrd:rvb i="2"/></ext></extLst></bk></futureMetadata><valueMetadata><bk><rc t="1" v="0"/></bk><bk><rc t="1" v="1"/></bk><bk><rc t="1" v="2"/></bk></valueMetadata></metadata>"#;
        let rvs = r#"<rvStructures xmlns="http://schemas.microsoft.com/office/spreadsheetml/2017/richdata"><s t="_webimage"><k n="WebImageIdentifier" t="i"/><k n="CalcOrigin" t="i"/><k n="ComputedImage" t="b"/><k n="ImageSizing" t="i"/><k n="Text" t="s"/></s></rvStructures>"#;
        let rv = r#"<rvData xmlns="http://schemas.microsoft.com/office/spreadsheetml/2017/richdata"><rv s="0"><v>0</v><v>5</v><v>1</v><v>1</v><v>A red square</v></rv><rv s="0"><v>1</v><v>5</v><v>1</v><v>1</v><v></v></rv><rv s="0"><v>2</v><v>5</v><v>1</v><v>1</v><v></v></rv></rvData>"#;
        let targets = HashMap::from([(
            "_webimage",
            ids.into_iter()
                .map(|i| i.map(|i| format!("xl/media/{i}.png")))
                .collect(),
        )]);
        let got = parse_rich_values(meta, rv, rvs, &targets);
        assert_eq!(got.len(), 2, "{got:?}");
        assert_eq!(
            got[&1],
            (
                "xl/media/rIdI1.png".to_string(),
                Some("A red square".to_string())
            )
        );
        assert!(
            !got.contains_key(&2),
            "the blip-less web image stays #VALUE!"
        );
        assert_eq!(got[&3], ("xl/media/rIdI3.png".to_string(), None));
    }

    #[test]
    fn scans_vm_cells() {
        let xml = r#"<sheetData><row r="2"><c r="B2" t="e" vm="1"><v>#VALUE!</v></c><c r="C2" t="n"><v>1</v></c><c r="AA10" vm="3" t="e"/></row></sheetData>"#;
        let got = cells_with_rich_values(xml);
        assert_eq!(got.len(), 2);
        assert_eq!(got[&(1, 1)], 1);
        assert_eq!(got[&(9, 26)], 3);
    }
}

/// docling#5271 (#1169): the `IMAGE()` fixtures end to end, and an image
/// that cannot be read losing its own data only
/// (`test_oversized_image_keeps_the_other_images`,
/// `test_truncated_image_keeps_the_other_images`).
#[cfg(test)]
mod image_function_tests {
    use crate::backend::DeclarativeBackend;
    use crate::format::InputFormat;
    use crate::source::SourceDocument;
    use std::io::{Read, Write};

    fn fixture(name: &str) -> Vec<u8> {
        let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
            .join("../../tests/data/xlsx/sources")
            .join(name);
        std::fs::read(path).expect(name)
    }

    /// The fixture with `member` replaced by `bytes`.
    fn replaced(name: &str, member: &str, bytes: &[u8]) -> Vec<u8> {
        let mut zin = zip::ZipArchive::new(std::io::Cursor::new(fixture(name))).unwrap();
        let mut zw = zip::ZipWriter::new(std::io::Cursor::new(Vec::new()));
        for i in 0..zin.len() {
            let mut f = zin.by_index(i).unwrap();
            let entry = f.name().unwrap().to_string();
            let mut data = Vec::new();
            f.read_to_end(&mut data).unwrap();
            if entry == member {
                data = bytes.to_vec();
            }
            zw.start_file(entry, zip::write::SimpleFileOptions::default())
                .unwrap();
            zw.write_all(&data).unwrap();
        }
        zw.finish().unwrap().into_inner()
    }

    /// Each picture's (description, has image data), in document order, and
    /// the Markdown.
    fn pictures(bytes: Vec<u8>) -> (Vec<(Option<String>, bool)>, String) {
        let src = SourceDocument::from_bytes("t.xlsx", InputFormat::Xlsx, bytes);
        let doc = crate::backend::XlsxBackend::default()
            .convert(&src)
            .expect("converts");
        let v: serde_json::Value = serde_json::from_str(&doc.export_to_json()).unwrap();
        let pics = v["pictures"]
            .as_array()
            .unwrap()
            .iter()
            .map(|p| {
                (
                    p["meta"]["description"]["text"]
                        .as_str()
                        .map(str::to_string),
                    p["image"].is_object(),
                )
            })
            .collect();
        (pics, doc.export_to_markdown())
    }

    #[test]
    fn images_from_the_image_function() {
        let (pics, md) = pictures(fixture("xlsx_11_image_function.xlsx"));
        assert_eq!(
            pics,
            [(Some("A red square".to_string()), true), (None, true)]
        );
        let row = |name: &str| {
            md.lines()
                .find(|l| l.starts_with(&format!("| {name} ")))
                .unwrap_or_default()
                .to_string()
        };
        assert!(row("red").contains("<!-- image -->  A red square"), "{md}");
        assert!(row("lost").contains("#VALUE!"), "{md}");
    }

    #[test]
    fn image_function_next_to_an_image_placed_in_a_cell() {
        let (pics, md) = pictures(fixture("xlsx_12_image_function_and_place_in_cell.xlsx"));
        assert_eq!(
            pics,
            [
                (Some("A yellow square".to_string()), true),
                (Some("A blue square".to_string()), true)
            ]
        );
        assert!(
            md.lines().any(
                |l| l.starts_with("| function ") && l.contains("<!-- image -->  A blue square")
            ),
            "{md}"
        );
    }

    #[test]
    fn an_unreadable_image_keeps_the_other_images() {
        let name = "xlsx_12_image_function_and_place_in_cell.xlsx";
        let original = {
            let mut zin = zip::ZipArchive::new(std::io::Cursor::new(fixture(name))).unwrap();
            let mut data = Vec::new();
            zin.by_name("xl/media/image1.png")
                .unwrap()
                .read_to_end(&mut data)
                .unwrap();
            data
        };
        // A PNG cut short, and one whose header declares 100000 × 100000.
        let truncated = original[..original.len() / 2].to_vec();
        let mut huge = original.clone();
        huge[16..20].copy_from_slice(&100_000u32.to_be_bytes());
        huge[20..24].copy_from_slice(&100_000u32.to_be_bytes());
        for broken in [truncated, huge] {
            for member in ["xl/media/image1.png", "xl/media/image2.png"] {
                let (pics, _) = pictures(replaced(name, member, &broken));
                assert_eq!(pics.len(), 2, "{member}: both cells stay pictures");
                let with_data = pics.iter().filter(|(_, data)| *data).count();
                assert_eq!(
                    with_data, 1,
                    "{member}: only the broken image loses its data"
                );
            }
        }
    }
}