![]() |
#1 |
Junior Member
![]() 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. |
![]() |
![]() |
![]() |
#2 |
Junior Member
![]() 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.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
want to learn what I want
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,481
Karma: 7030383
Join Date: Sep 2020
Device: none
|
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. |
![]() |
![]() |
![]() |
#4 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 44,799
Karma: 25490602
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
|
![]() |
![]() |
![]() |
#5 | |
Junior Member
![]() Posts: 5
Karma: 10
Join Date: Aug 2021
Device: Onyx Boox Palma
|
Quote:
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. |
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 44,799
Karma: 25490602
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.
|
![]() |
![]() |
![]() |
#7 |
Junior Member
![]() 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.
|
![]() |
![]() |
![]() |
#8 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 44,799
Karma: 25490602
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
So pass preserve_aspect_ratio=False to add_image_page()
|
![]() |
![]() |
![]() |
#9 |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 42,316
Karma: 162918680
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, 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.
|
![]() |
![]() |
![]() |
#10 |
Junior Member
![]() 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. |
![]() |
![]() |
![]() |
#11 |
Junior Member
![]() Posts: 1
Karma: 10
Join Date: Apr 2024
Location: St.Petersburg
Device: Onyx Boox Kon-Tiki 3
|
Please make it possible to create covers from the first page of the PDF.
|
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
[GUI Plugin] Generate Cover | kiwidude | Plugins | 844 | 01-15-2025 05:06 PM |
[GUI Plugin] Prettify Cover | m1d1 | Plugins | 63 | 03-19-2024 09:40 AM |
[GUI Plugin] Resize Cover | kiwidude | Plugins | 95 | 03-17-2024 12:55 AM |
[GUI Plugin] Prince PDF | Jellby | Plugins | 156 | 07-15-2023 12:39 PM |
[GUI Plugin] Save Virtual Libraries To Column (GUI) | chaley | Plugins | 14 | 04-04-2021 06:25 AM |