{"record":{"id":"0803ccd97f1fea6d","repo":"flxzt/rnote","slug":"image-format-not-set-to-a-bitmap-format","errorCode":null,"errorMessage":"image format not set to a bitmap format.","messagePattern":"image format not set to a bitmap format\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/rnote-engine/src/engine/export.rs","lineNumber":949,"sourceCode":"        let selection_export_prefs = SelectionExportPrefs {\n            export_format,\n            ..Default::default()\n        };\n\n        let content = self.extract_thumbnail_content(Vector2::new(size as f64, size as f64));\n        rayon::spawn(move || {\n            let result = || -> Result<Option<Vec<u8>>, anyhow::Error> {\n                let svg = content\n                    .gen_svg(\n                        selection_export_prefs.with_background,\n                        selection_export_prefs.with_pattern,\n                        selection_export_prefs.optimize_printing,\n                        selection_export_prefs.margin,\n                    )?\n                    .context(\"Unable to generate SVG from thumbnail content\")?;\n                let image_format = match export_format {\n                    SelectionExportFormat::Svg => {\n                        return Err(anyhow::anyhow!(\"image format not set to a bitmap format.\"));\n                    }\n                    SelectionExportFormat::Png => image::ImageFormat::Png,\n                    SelectionExportFormat::Jpeg => image::ImageFormat::Jpeg,\n                };\n\n                let image = svg.gen_image(1.0)?;\n                let (resize_width, resize_height) = {\n                    let width = image.pixel_width;\n                    let height = image.pixel_height;\n                    let ratio = if width >= height {\n                        // Landscape\n                        width as f64 / size as f64\n                    } else {\n                        // Portrait\n                        height as f64 / size as f64\n                    };\n                    let nwidth = width as f64 / ratio;\n                    let nheight = height as f64 / ratio;","sourceCodeStart":931,"sourceCodeEnd":967,"githubUrl":"https://github.com/flxzt/rnote/blob/bbc5354502ba2fc83eec2670b535348825e679a6/crates/rnote-engine/src/engine/export.rs#L931-L967","documentation":"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).","triggerScenarios":"Calling Engine::generate_thumbnail (e.g. from run_thumbnail for the file-chooser preview / recent-files thumbnailer) with export_format = SelectionExportFormat::Svg.","commonSituations":"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.","solutions":["Pass SelectionExportFormat::Png (the usual thumbnail format) or Jpeg to generate_thumbnail","If you only have Svg, render the Svg yourself with gen_image and then encode to a bitmap format","In callers like run_thumbnail, hard-default the format to Png and ignore/override any Svg value"],"exampleFix":"// before\nlet format = prefs.export_format; // may be Svg\nengine.generate_thumbnail(size, format).await?;\n// after\nlet format = match prefs.export_format {\n    SelectionExportFormat::Svg => SelectionExportFormat::Png,\n    f => f,\n};\nengine.generate_thumbnail(size, format).await?;","handlingStrategy":"validation","validationCode":"let format = match export_format {\n    SelectionExportFormat::Svg => SelectionExportFormat::Png,\n    f => f,\n};","typeGuard":"fn thumbnail_format(f: SelectionExportFormat) -> Option<SelectionExportFormat> {\n    match f {\n        SelectionExportFormat::Svg => None,\n        f => Some(f),\n    }\n}","tryCatchPattern":"match engine.generate_thumbnail(size, format).await {\n    Ok(t) => t,\n    Err(e) if e.to_string().contains(\"bitmap format\") => {\n        engine.generate_thumbnail(size, SelectionExportFormat::Png).await?\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Default thumbnails to Png","Never pass raw stored export prefs directly to the thumbnail API","Sanitize the format enum at the call boundary"],"tags":["thumbnail","image-format","enum","rust"],"backgroundTag":"unsupported-enum-value","analyzedSha":"bbc5354502ba2fc83eec2670b535348825e679a6","analyzedAt":"2026-09-08T13:20:33.747Z","contentChangedAt":"2026-09-08T13:20:33.747Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}