Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 02-05-2024, 06: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, 3637 views)
CaptainLexington is offline   Reply With Quote
Old 02-05-2024, 06: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, 02: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: 993
Karma: 6417070
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 05:39 AM.
Comfy.n is offline   Reply With Quote
Old 02-06-2024, 05: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,843
Karma: 22666666
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, 07: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, 10: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,843
Karma: 22666666
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, 01: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, 01: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,843
Karma: 22666666
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, 01: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: 35,311
Karma: 145435140
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, 01: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 01:29 AM.
CaptainLexington is offline   Reply With Quote
Old 04-11-2024, 01:39 AM   #11
Sergey Chaban
Junior Member
Sergey Chaban began at the beginning.
 
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.
Sergey Chaban is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[GUI Plugin] Prettify Cover m1d1 Plugins 63 03-19-2024 08:40 AM
[GUI Plugin] Resize Cover kiwidude Plugins 95 03-16-2024 11:55 PM
[GUI Plugin] Generate Cover kiwidude Plugins 811 03-16-2024 11:31 PM
[GUI Plugin] Prince PDF Jellby Plugins 156 07-15-2023 11:39 AM
[GUI Plugin] Save Virtual Libraries To Column (GUI) chaley Plugins 14 04-04-2021 05:25 AM


All times are GMT -4. The time now is 06:57 PM.


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