|
|
#1 |
|
Enthusiast
![]() 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. |
|
|
|
|
|
#2 |
|
want to learn what I want
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,283
Karma: 7971785
Join Date: Sep 2020
Device: Libra Colour
|
Here's a working version, based on the action chain posted by @ownedbycats in this thread:
https://www.mobileread.com/forums/sh....php?p=4474488 |
|
|
|
| Advert | |
|
|
|
|
#3 |
|
want to learn what I want
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,283
Karma: 7971785
Join Date: Sep 2020
Device: Libra Colour
|
Column definitions used:
PHP Code:
PHP Code:
PHP Code:
|
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Testers needed for Reading Tracker plugin | varia | Plugins | 69 | 04-26-2026 03:56 PM |
| Metadata Source Plugin, advice needed | Boilerplate4U | Development | 19 | 04-03-2021 03:41 AM |
| Help needed to create a plugin to add more shortcuts | celiapgt | Plugins | 11 | 06-28-2018 10:17 PM |
| An idea for a plugin - your opinions and help very welcome and needed! | TAtanasoska | Plugins | 1 | 11-15-2014 10:49 PM |
| New MOBI output plugin, testing needed | kovidgoyal | Conversion | 30 | 11-19-2011 04:52 PM |