07-26-2023, 09:41 AM | #1 |
Guru
Posts: 946
Karma: 1183425
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
|
Snippets
Hi,
I have a snippet for SVG covers: Code:
<?xml version='1.0' encoding='utf-8'?> <html xmlns="http://www.w3.org/1999/xhtml" lang="${1:pt-BR}" xml:lang="${2:pt-BR}"> <head> <title>${3:Capa}</title> <style type="text/css" title="override_css"> @page {padding: 0pt; margin:0pt} body { text-align: center; padding:0pt; margin: 0pt; } </style> </head> <body> <div> <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%" viewBox="0 0 ${4:903} ${5:1354}" preserveAspectRatio="xMidYMid meet"> <image width="${6:903}" height="${7:1354}" xlink:href="${8*:../Images/cover.jpg}"/> </svg> </div> </body> </html>$9 To start, I select the image path (e.g.: '../Images/cover.jpg') and press Ctrl+J. The snippet get this path and creates the SVG cover. All good, except for the image height and width, that I have to edit manually. My question: is it possible to get these attributes as parameters for the snippet? The manual doesn't mention it, but maybe it might be possible. P.S.: I know I can use the "Add cover" option. But it is very specific for covers, and the lang attribute is always "en". I also use this for other full page images as well. Last edited by thiago.eec; 07-26-2023 at 09:46 AM. |
07-26-2023, 10:24 AM | #2 |
creator of calibre
Posts: 44,033
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Not sure what you mean by parameters for snippets? Where would you enter the parameters? I suspect you mean you want to fill out the width and height only once. In that case use mirroring, see https://manual.calibre-ebook.com/snippets.html
|
07-26-2023, 10:36 AM | #3 | |
Guru
Posts: 946
Karma: 1183425
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
|
Quote:
P.S.: Thanks for the tip. I didn't know about mirroring. |
|
07-26-2023, 10:42 AM | #4 |
Well trained by Cats
Posts: 30,000
Karma: 57259778
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
I wondered why the Insert Image Tool did not have an AS SVG, tic option with all the expanded options (not just for covers)
Gotta ask: Why not just have Calibre (Main) embed the cover (and metadata)? |
07-26-2023, 10:57 AM | #5 | |
Guru
Posts: 946
Karma: 1183425
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
|
Quote:
Like I said, calibre uses lang="en", while my books are in "pt-BR". Also, the <title> attribute would be in english. And as for metadata, I rather do it myself, for best control. Also, I have to many custom columns that would be incorporated unnecessarily. |
|
07-26-2023, 11:42 AM | #6 | |
creator of calibre
Posts: 44,033
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Quote:
|
|
07-26-2023, 01:46 PM | #7 |
Guru
Posts: 946
Karma: 1183425
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
recover snippets only | rjwse@aol.com | Calibre | 2 | 10-10-2020 07:34 AM |
Random crashes using snippets | Phssthpok | Editor | 14 | 09-23-2017 10:58 PM |
Color code and snippets. | apoiata | Sigil | 14 | 02-22-2017 09:44 PM |
Snippets !!! Icon for the toolbar?? | phossler | Editor | 12 | 01-12-2015 05:05 AM |
Emailing snippets from Kindle... | gfmucci | Amazon Kindle | 0 | 05-17-2010 08:56 AM |