From abc81de37327ff451d9ab731098d7d8f2c81ccd2 Mon Sep 17 00:00:00 2001 From: xyzzy-foo Date: Fri, 16 Jan 2026 05:30:35 +0900 Subject: [PATCH] OPF2: Backport the fallback process for reading Open Manga Format (OMF) cover images to OPF2 The OMF cover image was not referenced in the KEPUB conversion because the EPUB Input plugin references OPF2 instead of OPF3. --- src/calibre/ebooks/metadata/opf2.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/calibre/ebooks/metadata/opf2.py b/src/calibre/ebooks/metadata/opf2.py index 8bb3f610ba..bfde49b4e4 100644 --- a/src/calibre/ebooks/metadata/opf2.py +++ b/src/calibre/ebooks/metadata/opf2.py @@ -1224,6 +1224,15 @@ class OPF: # {{{ mt = item.get('media-type', '') if mt and 'xml' not in mt and 'html' not in mt: return item.get('href', None) + # OMF files have the cover as the first item in the spine + first_ref = self.first_spine_item() + if first_ref: + for item in self.itermanifest(): + if item.get('href') == first_ref: + mt = item.get('media-type', '') + if mt and mt.lower() in {'image/jpeg', 'image/jpg', 'image/png', 'image/webp'}: + return first_ref + break @property def raster_cover(self):