|  03-29-2024, 05:46 PM | #1 | 
| Library Breeder (She/Her)            Posts: 1,301 Karma: 1937893 Join Date: Apr 2015 Location: Fullerton, California Device: Paperwhite 2015 (2), PW 2024 (12 GEN), PW 2023 (11 GEN), Scribe (1st) | 
				
				column for cover size
			 
			
			I wanted to make a custom column showing the coversize of the book how would I go about doing that? - I'm trying to find covers that don't show well on my Kindle and by knowing the size of the covers that DO show well, I can find the ones that don't and then change their sizes.
		 | 
|   |   | 
|  03-29-2024, 09:08 PM | #2 | 
| Well trained by Cats            Posts: 31,241 Karma: 61360164 Join Date: Aug 2009 Location: The Central Coast of California Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A | 
			
			Rather than a column... The Quality check plugin: Check Covers: <select>Less than <value> All you need to do is figure what your threshold of cover size tolerance is.   | 
|   |   | 
|  03-30-2024, 08:23 AM | #3 | 
| Grand Sorcerer            Posts: 12,525 Karma: 8065948 Join Date: Jan 2010 Location: Notts, England Device: Kobo Libra 2 | 
			
			Directly answering the question ... In the past you haven't seemed interested in solutions involving composite columns and templates, but just in case I am wrong, here is one. It returns the width and height of the cover image. Performance isn't excellent because it must read the actual cover file off the disk. I suggest that if you use it then you display the results in book details and not in the book list making performance much less of an issue. You would put this in a "Column built from other columns" with "Show as html" unchecked. You could check "Show in Tag browser" but it isn't obvious why you would want this. Code: python:
def evaluate(book, context):
	from io import BytesIO
	from PIL import Image
	mi = context.db.new_api.get_metadata(book.id, get_cover=True, cover_as_data=True)
	if mi.cover_data[1] is not None:
		pm = Image.open(BytesIO(mi.cover_data[1]))
		ans = f'w={str(pm.width)}, h={str(pm.height)}'
	else:
		ans = 'No cover'
	return ansLast edited by chaley; 03-30-2024 at 08:25 AM. Reason: Added screen capture showing the output | 
|   |   | 
|  03-30-2024, 04:38 PM | #4 | 
| Library Breeder (She/Her)            Posts: 1,301 Karma: 1937893 Join Date: Apr 2015 Location: Fullerton, California Device: Paperwhite 2015 (2), PW 2024 (12 GEN), PW 2023 (11 GEN), Scribe (1st) | 
			
			Actually, it's not that I'm not interested in using templates or custom columns, it's that I for some reason have had problems trying to figure out coding. I'm like the person who doesn't know carpentry but is trying to build a table with ductape and glue. Still get a table, but it's a bit clunky. Thanks for the column instructions. I will update to see how it works. What I will do, is make the column, then create a second tag column or text column that will be blank. Then when the custom column populates, I can copy it over to the blank column then delete the custom column. I am not sure, if a column isn't being shown in the booklist, does it still populate and make the program slow? Also, theducks suggestion of the book check plugin was actually running through my mind just before I saw his response. I will try the column just to stretch my abilities though. I need to really learn how to code and make templates. I have actually used Chat AI for creating scripts for stuff in the past to go through batches of files for things. It actually worked! Last edited by Rellwood; 03-30-2024 at 04:41 PM. | 
|   |   | 
|  03-30-2024, 06:31 PM | #5 | |||
| Grand Sorcerer            Posts: 12,525 Karma: 8065948 Join Date: Jan 2010 Location: Notts, England Device: Kobo Libra 2 | Quote: 
 Quote: 
 
 Versions of calibre before 7.7 would evaluate the columns if book details might be shown even if the details never were actually shown. Because of this, scrolling through the booklist could be slow. I hope that problem is now gone. Quote: 
   | |||
|   |   | 
|  03-30-2024, 10:21 PM | #6 | |
| Bibliophagist            Posts: 48,058 Karma: 174315300 Join Date: Jul 2010 Location: Vancouver Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos | Quote: 
 Somewhere in the basement, I still have the code and output from the first WatFOR program I wrote in 1968 that actually ran. I used the 3-way arithmetic IF a few times and committed multiple other sins making debugging the program a total pain. | |
|   |   | 
|  03-30-2024, 10:27 PM | #7 | |
| want to learn what I want            Posts: 1,679 Karma: 7908443 Join Date: Sep 2020 Device: none | Quote: 
 Spoiler: 
 And it also helped creating a similar AHK script. I guess it works well for programming stuff that don't require too much critical 'thinking' Last edited by Comfy.n; 03-30-2024 at 11:23 PM. | |
|   |   | 
|  03-30-2024, 11:05 PM | #8 | 
| creator of calibre            Posts: 45,601 Karma: 28548974 Join Date: Oct 2006 Location: Mumbai, India Device: Various | 
			
			Anything beyond trivial, small, well documented on the internet examples it tends to fail at, and fail in non obvious ways, often inventing API functions that would do what the user asked but that dont actually exist. That said, if you are new to an area it is a great way to get started and to get pointers to areas of the API that would take you much longer to find by traditional methods of exploration.
		 | 
|   |   | 
|  03-30-2024, 11:57 PM | #9 | ||
| Custom User Title            Posts: 11,340 Karma: 79528341 Join Date: Oct 2018 Location: Canada Device: Kobo Libra H2O, formerly Aura HD | Quote: 
 Quote: 
 | ||
|   |   | 
|  | 
| 
 | 
|  Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| size in kb column | Rellwood | Library Management | 5 | 03-09-2021 05:55 PM | 
| cover size - epub what's a good size? | christopher22 | Calibre | 3 | 01-19-2019 04:56 PM | 
| Column for cover size? | Black Scholes | Library Management | 2 | 11-08-2013 03:07 AM | 
| size column | iomari | Calibre | 6 | 09-30-2011 07:00 AM | 
| Cover Size Column? | transmitthis | Library Management | 5 | 06-19-2011 06:27 AM |