tonhowtf/omniget · error · anyhow::Error
a capa {cover} não é PNG, JPEG, GIF ou BMP
Error message
a capa {cover} não é PNG, JPEG, GIF ou BMP What it means
This error is thrown when a cover image supplied via opts.cover_path was read successfully but mime_of() could not detect PNG, JPEG, GIF or BMP magic bytes in the file's data. The library only supports embedding covers in those four formats, and refuses any other file type (or an unrecognized one) rather than passing a bogus MIME type to the lofty tag writer. The file path is interpolated into the message so the user knows which cover was rejected.
Solutions
- Convert the cover to PNG or JPEG before passing the path (e.g. with imagemagick: magick input.webp cover.png).
- Verify the file is actually an image of an allowed type: run `file <cover>` or check the first bytes for PNG/JPEG/GIF/BMP signatures.
- If the cover is optional, leave opts.cover_path empty/None so no cover is attached.
- Extend mime_of() to support additional formats if WebP etc. are genuinely needed and lofty accepts them.
Example fix
// before
let data = std::fs::read("cover.webp")?; // mime_of -> None
let mime = mime_of(&data).ok_or_else(|| anyhow!("a capa {cover} não é PNG, JPEG, GIF ou BMP"))?;
// after
// convert first: `magick cover.webp cover.png`, then
let data = std::fs::read("cover.png")?;
let mime = mime_of(&data).ok_or_else(|| anyhow!("a capa {cover} não é PNG, JPEG, GIF ou BMP"))?; Defensive patterns
Strategy: validation
Validate before calling
fn is_supported_cover(path: &str) -> anyhow::Result<bool> {
let data = std::fs::read(path)?;
Ok(mime_of(&data)
.map(|m| matches!(m, "image/png" | "image/jpeg" | "image/gif" | "image/bmp"))
.unwrap_or(false))
} Type guard
fn is_image_mime(mime: &str) -> bool {
matches!(mime, "image/png" | "image/jpeg" | "image/gif" | "image/bmp")
} Try / catch
match edit_tags_with_cover(path, cover) {
Ok(change) => /* aplicar */,
Err(e) if e.to_string().contains("não é PNG, JPEG, GIF ou BMP") =>
eprintln!("capa em formato não suportado: converta para PNG/JPEG/GIF/BMP"),
Err(e) => return Err(e),
} Prevention
- Always run the file through `file`/magic-byte sniffing before attaching a cover.
- Prefer PNG or JPEG covers downloaded from album-art sources.
- Convert WebP/AVIF downloads to PNG automatically at import time.
- Leave cover_path empty when unsure instead of guessing the format.
When it happens
Trigger: Calling the audio tag editing function with opts.cover_path set to a file that is not a PNG/JPEG/GIF/BMP (e.g. WebP, TIFF, SVG, AVIF) or a file whose leading bytes mime_of() cannot recognize (corrupted image, text file renamed to .png).
Common situations: User picks a modern WebP/AVIF image downloaded from the web as album art; a placeholder or HTML error page saved as cover.jpg; an image so truncated that its magic bytes are missing.
Related errors
- escolha a pasta de destino para organizar
- informe um appid, um link da loja ou marque a biblioteca int
- pasta de origem não encontrada: {}
- escolha a pasta da biblioteca de destino
- external_data_cache: plugin_id must not be empty
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/528c26645252e237.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/audio_tag.rs:1232
fn edit_one(path: &Path, diffs: &[FieldDiff], opts: &EditOptions) -> anyhow::Result<FileChange> {
let path_str = path.to_string_lossy().to_string();
let mut change = FileChange {
path: path_str.clone(),
file_name: file_name_of(&path_str),
diffs: diffs.to_vec(),
cover: None,
unsupported: Vec::new(),
written: false,
backup: None,
error: None,
};
let cover_bytes = if let Some(cover) = opts.cover_path.as_deref().filter(|s| !s.is_empty()) {
let data =
std::fs::read(cover).with_context(|| format!("não consegui ler a capa em {cover}"))?;
let mime =
mime_of(&data).ok_or_else(|| anyhow!("a capa {cover} não é PNG, JPEG, GIF ou BMP"))?;
Some((data, mime))
} else {
None
};
let mut tagged = lofty::read_from_path(path).map_err(|e| anyhow!(e.to_string()))?;
let tag_type = tagged.primary_tag_type();
if tagged.primary_tag_mut().is_none() {
tagged.insert_tag(Tag::new(tag_type));
}
let tag = tagged
.primary_tag_mut()
.ok_or_else(|| anyhow!("o formato não aceita a tag {tag_type:?}"))?;
let before_cover = tag.pictures().len();
let before_bytes: u64 = tag.pictures().iter().map(|p| p.data().len() as u64).sum();
change.unsupported = apply_diffs(tag, diffs);View on GitHub (pinned to 8600b91f42)