View Single Post
Old 06-21-2026, 05:51 PM   #1
cgrapski
Enthusiast
cgrapski began at the beginning.
 
Posts: 42
Karma: 10
Join Date: Dec 2016
Device: Kindle
Plugin : Help needed

I created a plugin to put cover image data in columns. It loads and is enabled - but I don't get a choice to add it to a toolbar.

I created a ui.py file - this is it:
Code:
from calibre.customize import InterfaceActionBase
from calibre.gui2.actions import InterfaceAction
from calibre.gui2 import info_dialog
from calibre.utils.magick import Image
import os


class CoverSizeChecker(InterfaceActionBase):
    name = 'Cover Size Checker'
    description = 'Scan cover sizes and update #cover_width, #cover_height, and #cover_small.'
    supported_platforms = ['windows', 'osx', 'linux']
    author = 'Charlie'
    version = (1, 0, 0)
    minimum_calibre_version = (6, 0, 0)
    actual_plugin = 'calibre_plugins.CoverSizeChecker:CoverSizeCheckerAction'


class CoverSizeCheckerAction(InterfaceAction):
    name = 'Cover Size Checker'

    def genesis(self):
        self.qaction.triggered.connect(self.run)

    def run(self):
        gui = self.gui
        db = gui.current_db
        updated = 0
        small = []

        for book_id in db.all_book_ids():
            mi = db.get_metadata(book_id, index_is_id=True)
            cover = db.cover(book_id)

            if not cover or not os.path.exists(cover):
                continue

            try:
                img = Image()
                img.load(cover)
                w, h = img.width, img.height
            except Exception:
                continue

            mi.set('#cover_width', str(w))
            mi.set('#cover_height', str(h))

            if w < 450:
                mi.set('#cover_small', 'yes')
                small.append(f'{mi.title} — {w}x{h}')
            else:
                mi.set('#cover_small', 'no')

            db.set_metadata(book_id, mi)
            updated += 1

        msg = f'Updated {updated} books.\n\n'
        if small:
            msg += 'Small covers (

Last edited by PeterT; 06-21-2026 at 09:33 PM.
cgrapski is offline   Reply With Quote