|
|
#1 |
|
Enthusiast
![]() Posts: 43
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,291
Karma: 7990245
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 |
|
|
|
|
|
#3 |
|
want to learn what I want
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,291
Karma: 7990245
Join Date: Sep 2020
Device: Libra Colour
|
Column definitions used:
PHP Code:
PHP Code:
PHP Code:
|
|
|
|
|
|
#4 | |
|
Enthusiast
![]() Posts: 43
Karma: 10
Join Date: Dec 2016
Device: Kindle
|
Thank You - But It Worked but Didn't Work - Not Sure Why
Quote:
Thank you. This worked - as far as it allowed me to add to the Tool Bar - and then it ran (it took a long time to do the whole library - not sure if I am able to run it on only portions - and a progress bar would be desirable). It successfully identified the cover sizes and those that I defined as "small" - (and it gave me a list of books it identified (but there were too many for it to list them all - but those that it did it told me the title and the height and width). But it (and it told me when it finished this was the case) it wrote nothing (updated 0 records) to the columns. I don't know why. The custom columns that should have been updated were #cover_small and #cover_width and #cover_height. |
|
|
|
|
|
|
#5 |
|
want to learn what I want
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,291
Karma: 7990245
Join Date: Sep 2020
Device: Libra Colour
|
try the attached 2.0 version.
I haven't dared to run it on my main 80K library but it seems robust and will create the custom columns on single click. You can use either Scan selected or Scan all books. |
|
|
|
![]() |
|
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 |