View Single Post
Old 12-16-2024, 08:20 AM   #1041
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 10,998
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Quote:
Originally Posted by chaley View Post
There is no existing built-in way to get the cover size. It can be done in a python template but that requires opening the cover to compute its size, which could be too slow to use. What is "too slow" is up to you.

The template returns the cover size as "width by height". You can play with the formatting.
Code:
python:
def evaluate(book, context):
	db = context.db.new_api
	cover = db.cover(book.id, as_image=True)
	width = cover.width()
	height = cover.height()
	if width and height:
		return f'{str(width)} by {str(height)}'
	return '--'
Also attached is an Action Chain (instructions to install) will writes the template output to a #coversize column with less performance issues.
Attached Files
File Type: zip UpdateCoverSize.zip (2.6 KB, 387 views)

Last edited by ownedbycats; 12-16-2024 at 10:29 AM.
ownedbycats is offline   Reply With Quote