{"record":{"id":"a06db5ba53cc2703","repo":"tonhowtf/omniget","slug":"n-o-abri-a-imagem","errorCode":null,"errorMessage":"não abri a imagem: {}","messagePattern":"não abri a imagem: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/image_compress.rs","lineNumber":136,"sourceCode":"    let scale = max_side as f32 / img.width().max(img.height()) as f32;\n    img.resize(\n        ((img.width() as f32 * scale).round() as u32).max(1),\n        ((img.height() as f32 * scale).round() as u32).max(1),\n        FilterType::Lanczos3,\n    )\n}\n\nfn flatten(img: &DynamicImage, hex: &str) -> DynamicImage {\n    let bg = super::icon_pack::parse_hex(hex);\n    let mut canvas = image::RgbaImage::from_pixel(img.width(), img.height(), bg);\n    image::imageops::overlay(&mut canvas, &img.to_rgba8(), 0, 0);\n    DynamicImage::ImageRgba8(canvas)\n}\n\nfn compress_one(opts: &CompressOptions, input: &str) -> anyhow::Result<CompressItem> {\n    let inp = Path::new(input);\n    let bytes_before = std::fs::metadata(inp).map(|m| m.len()).unwrap_or(0);\n    let mut img = image::open(inp).map_err(|e| anyhow!(\"não abri a imagem: {}\", e))?;\n    if img.color().has_alpha() {\n        img = flatten(&img, &opts.background);\n    }\n    img = resize_to_side(&img, opts.max_side);\n    let mut scaled = opts.max_side > 0 && img.width().max(img.height()) == opts.max_side;\n\n    let (data, quality, hit) = if opts.target_kb > 0 {\n        let target = opts.target_kb * 1024;\n        let (mut data, mut quality, mut fits) = fit_quality(&img, target, 40, 95)?;\n        // Nem no melhor caso coube: cede qualidade e depois vai encolhendo.\n        // Foto ruidosa precisa de muitas rodadas; parar em três deixava o\n        // usuário com um arquivo acima do alvo e nenhuma explicação.\n        let mut tries = 0;\n        while !fits && tries < 8 {\n            let floor = if tries < 2 { 30 } else { 20 };\n            let side = (img.width().max(img.height()) as f32 * 0.8).round() as u32;\n            if side < 200 {\n                break;","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/image_compress.rs#L118-L154","documentation":"Open failure in compress_one: the input file could not be opened or decoded by the image crate — wrong path, unreadable file, or unsupported/corrupt image format — so this item is marked failed instead of compressed.","triggerScenarios":"Thrown at src-tauri/omniget-core/src/core/tools/image_compress.rs:136 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Confirm the file path is correct and readable","Convert the image to a supported format (JPEG/PNG/WebP) before batch compression","Skip the corrupt file and continue with the rest of the batch"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}