View Single Post
Old 01-13-2026, 08:31 AM   #313
un_pogaz
Chalut o/
un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.un_pogaz ought to be getting tired of karma fortunes by now.
 
un_pogaz's Avatar
 
Posts: 664
Karma: 720026
Join Date: Dec 2017
Device: Kobo
Quote:
Originally Posted by ownedbycats View Post
Template is just {#pagecount}. My books vary from just 1 page to ~15,000 (super-long fanfic).
Ah, yep don't work like that.
The template require a decimal value bettwen 0.0 to 1.0 (min/max), so put it a raw field dosn't work. {pages} work because Calibre detect it as a special field and do a transform behind.

To use a custom column use the button "Use a custom column" and select the one you want (or pick anyone and open the editor to set the correct field)

You should end up with this as your template:
Code:
python:
from calibre.gui2.library.bookshelf_view import width_from_pages

def evaluate(book, context):
    val = book.get('#pagecount')
    try:
        pages = max(0, int(val))
    except Exception:
        return '0.3'
    return str(width_from_pages(pages, num_of_pages_for_max_width=1500, logarithmic_factor=2))
From them, you can edit the parameter "num_of_pages_for_max_width" to the max page you want, but I do not recommend using 15,000, because is rare and the vast majority of books will be bellow that, so every books will be narrowed. Better 5,000 or 10,000, to you to see.

The "logarithmic_factor" parameter is here for give more width to book that bellow the average, so that the render spine was not all too narrow. Bigger is, bigger the small book have bigger width. Tweak this if you want, but their is not recomendation for that (advanced settings)
un_pogaz is offline   Reply With Quote