flxzt/rnote · error

image format not set to a bitmap format.

Error message

image format not set to a bitmap format.

What it means

generate_thumbnail renders the current document content to an image, and only supports bitmap output. It maps the requested export_format and returns this error when the format is SelectionExportFormat::Svg, because a thumbnail must be a raster image (Png or Jpeg).

Solutions

  1. Pass SelectionExportFormat::Png (the usual thumbnail format) or Jpeg to generate_thumbnail
  2. If you only have Svg, render the Svg yourself with gen_image and then encode to a bitmap format
  3. In callers like run_thumbnail, hard-default the format to Png and ignore/override any Svg value

Example fix

// before
let format = prefs.export_format; // may be Svg
engine.generate_thumbnail(size, format).await?;
// after
let format = match prefs.export_format {
    SelectionExportFormat::Svg => SelectionExportFormat::Png,
    f => f,
};
engine.generate_thumbnail(size, format).await?;
Defensive patterns

Strategy: validation

Validate before calling

let format = match export_format {
    SelectionExportFormat::Svg => SelectionExportFormat::Png,
    f => f,
};

Type guard

fn thumbnail_format(f: SelectionExportFormat) -> Option<SelectionExportFormat> {
    match f {
        SelectionExportFormat::Svg => None,
        f => Some(f),
    }
}

Try / catch

match engine.generate_thumbnail(size, format).await {
    Ok(t) => t,
    Err(e) if e.to_string().contains("bitmap format") => {
        engine.generate_thumbnail(size, SelectionExportFormat::Png).await?
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling Engine::generate_thumbnail (e.g. from run_thumbnail for the file-chooser preview / recent-files thumbnailer) with export_format = SelectionExportFormat::Svg.

Common situations: Passing through stored user prefs or a CLI/DBus thumbnail request where the format enum defaults to or was set to Svg instead of Png; adapting doc-pages export code to the thumbnail path without changing the format.

Related errors


AI-assisted analysis of flxzt/rnote@bbc5354502 (2026-09-08). Data as JSON: /api/errors/0803ccd97f1fea6d. Report an issue: GitHub.

Appendix: source

Thrown at crates/rnote-engine/src/engine/export.rs:949

        let selection_export_prefs = SelectionExportPrefs {
            export_format,
            ..Default::default()
        };

        let content = self.extract_thumbnail_content(Vector2::new(size as f64, size as f64));
        rayon::spawn(move || {
            let result = || -> Result<Option<Vec<u8>>, anyhow::Error> {
                let svg = content
                    .gen_svg(
                        selection_export_prefs.with_background,
                        selection_export_prefs.with_pattern,
                        selection_export_prefs.optimize_printing,
                        selection_export_prefs.margin,
                    )?
                    .context("Unable to generate SVG from thumbnail content")?;
                let image_format = match export_format {
                    SelectionExportFormat::Svg => {
                        return Err(anyhow::anyhow!("image format not set to a bitmap format."));
                    }
                    SelectionExportFormat::Png => image::ImageFormat::Png,
                    SelectionExportFormat::Jpeg => image::ImageFormat::Jpeg,
                };

                let image = svg.gen_image(1.0)?;
                let (resize_width, resize_height) = {
                    let width = image.pixel_width;
                    let height = image.pixel_height;
                    let ratio = if width >= height {
                        // Landscape
                        width as f64 / size as f64
                    } else {
                        // Portrait
                        height as f64 / size as f64
                    };
                    let nwidth = width as f64 / ratio;
                    let nheight = height as f64 / ratio;

View on GitHub (pinned to bbc5354502)