Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 02-05-2024, 07:50 PM   #1
CaptainLexington
Junior Member
CaptainLexington began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Aug 2021
Device: Onyx Boox Palma
[GUI Plugin] PDF Cover

What
This plugin inserts your Calibre cover as the first page of the book's PDF.

Why
Most ereader software uses the first page of the PDF as the de facto cover. Many PDFs, such as public domain books from Internet Archive or Google Books, have first pages that are poorly suited for that purpose.

How
It uses pypdf to insert your cover file, so pypdf is a bundled dependency. It also adds a flag to the PDF metadata, so if you change the cover later, it replaces the first page instead of inserting another one.

Where
Download the plugin below. Contribute on GitHub. There is also a more detailed readme there.

When
As of 2024.02.05, the current version is 0.1.0, an alpha release. This is also my first Calibre plugin. Use with caution.
Attached Files
File Type: zip pdf_cover_0.1.0.zip (2.12 MB, 1164 views)
CaptainLexington is offline   Reply With Quote
Old 02-05-2024, 07:51 PM   #2
CaptainLexington
Junior Member
CaptainLexington began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Aug 2021
Device: Onyx Boox Palma
Other people seem to think it is important to reserve the first reply for later revision.
CaptainLexington is offline   Reply With Quote
Advert
Old 02-06-2024, 03:22 AM   #3
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
Posts: 832
Karma: 5678910
Join Date: Sep 2020
Device: Calibre E-book viewer
Hi! I think this is a most welcome addition as I recall I did sometimes in the past indeed miss a quick way to insert the current Calibre cover (the one displayed in Book Details pane) as the first PDF page. Today I'm running Calibre from latest source, and I can confirm the plugin is working great. Toolbar icon looks very distinctive in dark mode. Thanks and congratulations!

For extra PDF operations, like undoing first page insertion, merging, extracting etc. there are many open source alternatives, like PDFsam basic and such.


Last edited by Comfy.n; 02-06-2024 at 06:39 AM.
Comfy.n is online now   Reply With Quote
Old 02-06-2024, 06:27 AM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,672
Karma: 22446734
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Note that you dont need to use pypdf you can use the existing add_image_page() function in calibre.utils.podofo
kovidgoyal is online now   Reply With Quote
Old 02-07-2024, 08:18 PM   #5
CaptainLexington
Junior Member
CaptainLexington began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Aug 2021
Device: Onyx Boox Palma
Quote:
Originally Posted by kovidgoyal View Post
Note that you dont need to use pypdf you can use the existing add_image_page() function in calibre.utils.podofo
I have gotten this working, but I'm not sure I like the white padding when the aspect ratio doesn't match. I'll have to try this on several books and see how I like it on my ereader.

Also, forgive me if this is the wrong place to ask, but I am having trouble understanding how to write the custom PDF metadata flag to indicate subsequent covers should overwrite the existing Page 1. I'm using podofo.set_metadata, and it doesn't crash anymore, but the flag I'm trying to save ("HasCustomPDFCover") isn't showing up in the XMP metadata when I reload the file.
CaptainLexington is offline   Reply With Quote
Advert
Old 02-07-2024, 11:24 PM   #6
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,672
Karma: 22446734
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
set_metadata works with calibre metadata objects, which dont have any such field. You would need to use get_xmp_metadata to ge tthe raw XMP, change it however you need and then use set_xmp_metadata to update it.
kovidgoyal is online now   Reply With Quote
Old 02-08-2024, 02:06 AM   #7
CaptainLexington
Junior Member
CaptainLexington began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Aug 2021
Device: Onyx Boox Palma
Okay, I got it working, but I still don't like the padding to match the aspect ratio. The difference in bundle size is only about 300k, so I'm going to keep pypdf as a dependency for now.
CaptainLexington is offline   Reply With Quote
Old 02-08-2024, 02:08 AM   #8
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,672
Karma: 22446734
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
So pass preserve_aspect_ratio=False to add_image_page()
kovidgoyal is online now   Reply With Quote
Old 02-08-2024, 02:15 AM   #9
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 33,652
Karma: 142904165
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Personally, I would prefer making distorting the cover image an option so those of us who prefer the undistorted cover images can keep them.
DNSB is offline   Reply With Quote
Old 02-08-2024, 02:26 AM   #10
CaptainLexington
Junior Member
CaptainLexington began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Aug 2021
Device: Onyx Boox Palma
The current implementation matches the cover image to the height or the width of the last page of the PDF, whichever is greater, and preserves the aspect ratio of the original file, which results in a PDF whose first page may be a different aspect ratio from subsequent pages.

I think this is preferable to either distorting or padding the image to match the aspect ratio of subsequent pages.* It is important both that the thumbnails of the books look attractive on all reader software that supports such thumbnails, and that the reading experience not be made inconvenient.

*(I also found that sometimes using add_image_page the inserted cover would be larger than the subsequent pages, even if it matched the aspect ratio. I believe this happened when the source image was already higher resolution than the images of the pages, but I didn't do enough testing to confirm this.)

But this is just my opinion, and if as seems true this plugin already has active users, their opinions surely count as well, especially because my setup (KOReader on a BOOX Palma) is going to be pretty niche. I would love to hear what the experience on Kindle, Kobo, and Nook is like, as well as for users who read PDFs on their computers.

It seems that configuration options are inevitable, but this is something I may not be able to get around to implementing for a while (though I will gratefully review pull requests!). Thank you, Kovid, for your assistance, and obviously for making Calibre in the first place!

Last edited by CaptainLexington; 02-08-2024 at 02:29 AM.
CaptainLexington is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[GUI Plugin] Generate Cover kiwidude Plugins 810 09-04-2023 01:53 AM
[GUI Plugin] Prince PDF Jellby Plugins 156 07-15-2023 12:39 PM
[GUI Plugin] Resize Cover kiwidude Plugins 94 10-16-2022 03:28 PM
[GUI Plugin] Prettify Cover m1d1 Plugins 62 09-27-2022 09:19 PM
[GUI Plugin] Save Virtual Libraries To Column (GUI) chaley Plugins 14 04-04-2021 06:25 AM


All times are GMT -4. The time now is 12:34 AM.


MobileRead.com is a privately owned, operated and funded community.