View Single Post
Old 12-16-2024, 06:05 AM   #2
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,451
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
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 '--'
Example output:
Attached Thumbnails
Click image for larger version

Name:	Clipboard01.jpg
Views:	145
Size:	5.7 KB
ID:	212514  
chaley is offline   Reply With Quote