![]() |
#1 |
Junior Member
![]() Posts: 6
Karma: 10
Join Date: May 2017
Device: PRS-505
|
Batch Convert epubs to mirrored versions
Hello,
I am trying to bulk convert epubs from a variety of sources to new epub entries that are mirrored versions of themselves (so the text would read correctly if viewed in a mirror; images can be mirrored or not). So far I have done this to a few individual books using Sigil, adding something like the following the the stylesheet: .body { display: block; -webkit-transform: scale(-1,1) } And then adding a <div class="body"> tag at the beginning of <body> for each of the html files, closing it at the end of the document. I do not know if this is the best or most efficient way but it displays correctly mirrored in calibre and on my phone. It works well but I would like to do it for a couple hundred epubs, which would be time consuming, so I thought calibre conversion might be the answer. These epubs come from a variety of sources, from project gutenburg to library downloads and others. Is there any way to batch convert them all to mirrored versions of themselves? Better yet, to produce new entries in calibre, each with the original title + "Mirrored", and a different UUID so that my phone will recognize them as distinct? Thanks in advance for your help, I am happy to add any information necessary. *** P.S. A success story: I could not display these mirrored epubs as such on my old Sony PRS-505, but I did use calibre to convert them to PDFs that could be easily read! |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,347
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You can specify any css you like during conversion in the Look & Feel->Styling section fo the conversion dialog
|
![]() |
![]() |
![]() |
#3 |
Junior Member
![]() Posts: 6
Karma: 10
Join Date: May 2017
Device: PRS-505
|
Ok, I tried that, my test epub was Verne's Off on a Comet
I tried adding the following to the css: .calibre { -webkit-transform: scale(-1,1); background: #faebd0; background-color: white; color: black; display: block; font-size: 1em; text-align: justify; width: auto; padding: 0; margin: 0 5pt; border: currentColor none 0 } (That is an exact copy of the .calibre entry in the .css file after converting the book with all the presets. I just added the first line and tried again with the original file) It completely failed; no matter whether I pointed to a new .css file with that as an entry or had it as raw css, the output file was the same and no transform took place. I am perplexed because that seemed an obvious and easy answer. |
![]() |
![]() |
![]() |
#4 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,347
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Use body {} not .calibre {}
|
![]() |
![]() |
![]() |
#5 |
Junior Member
![]() Posts: 6
Karma: 10
Join Date: May 2017
Device: PRS-505
|
That worked great, thanks!
A follow-up question: any recommendations for how to get the outputs to be different entries than the originals? I was thinking I would just edit the metadata of the converted outputs in bulk by adding "Mirrored" to the end of each title and "-1" to each UUID (and then reimport the original books from back-ups after deleting the .original_epub files). But I cannot see a way to add a word to the title of multiple books in the bulk metadata edit, since it is only search/replace. I guess I still could modify the UUID at least, replacing each "-" with "-0-" or something, but I welcome a way to add a simple word at the end of many titles at once if you might know of one. |
![]() |
![]() |
![]() |
#6 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,347
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Use
(.*) as the search (in regex mode) and \1 Mirrored as the replacement. |
![]() |
![]() |
![]() |
#7 |
Junior Member
![]() Posts: 6
Karma: 10
Join Date: May 2017
Device: PRS-505
|
Awesome, editing the titles/uuids works great!
However, unexpected problem with the conversion: when I try to open a mirrored book using calibre's epub reader, it will only let me see the first part of each chapter. Scrolling and the up/down buttons do not work (the position and numbers change but the displayed text does not, until the next chapter arrives). The non-converted books work fine (still using Verne's Off on a Comet as the main test case). The books do work completely fine on my phone though. Worse, when I tried to convert the mirrored books from epub to pdf to read on my e-reader, (A6 paper size, margins 5 pts all around, other presets unchanged), it only gave me the first page of every section for each book. This was not a problem with the previous books I converted to mirrored in Sigil, either the reader issue or the pdf conversion issue. Just curious what might have caused it and how to resolve it or modify the conversion process to work around it. |
![]() |
![]() |
![]() |
#8 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,347
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
No idea -- -webkit-transform is not exactly a standard part of the ebook toolkit
![]() I suggest you do a conversion without it. Check that the converted book works. Then add it to the css of the converted book using the calirbe editor or sigil and see if it still works. Then do another conversion of the converted book this time with the css and see what is different between the two converted books. |
![]() |
![]() |
![]() |
#9 |
Junior Member
![]() Posts: 6
Karma: 10
Join Date: May 2017
Device: PRS-505
|
Thanks for the recommendation, here is what I have discovered:
if -webkit-transform is in the class "x" where x=calibre (through conversion with extra css or addition after conversion), or x=mirrored (through addition to css after conversion), then <body class="x"> [pages of text/images] </body> Reproduces the problems noted above. However, if I create a new class "mirrored" post-conversion, then <body class="calibre"> <div class="mirrored"> [pages of text/images] </div> </body> Works and displays fine. No idea why. So I guess my question now has become: how to add a new class ("mirrored") to the css, and is there any way to automate the insertion of a <div class="mirrored"> immediately after every <body class="calibre"> during the conversion process? I assume the former is easy enough, though when tried the extra css script with .mirrored {-webkit-transform: scale(-1, 1)}, it was completely missing from the stylesheet at the end. I am clueless when it comes to the latter. |
![]() |
![]() |
![]() |
#10 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,347
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Use the searchand replace function to replace
<body[^>]*> with <body><div style="-webkit-transform: scale(-1, 1)"> |
![]() |
![]() |
![]() |
#11 |
Junior Member
![]() Posts: 6
Karma: 10
Join Date: May 2017
Device: PRS-505
|
Success!
|
![]() |
![]() |
![]() |
Tags |
bulk, convert epub to epub, epub, mirrored, mirroring |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Python script: batch create mobi's from epubs (if they don't exist) | jmeb | Conversion | 0 | 05-20-2011 01:14 PM |
How to batch-convert with ebook-convert? | cypresstwist | Conversion | 8 | 02-22-2011 09:28 AM |
Command Line Batch Adding of Epubs | nkormanik | Calibre | 6 | 10-19-2010 08:04 AM |
Batch convert error | Dopedangel | Calibre | 2 | 09-07-2009 03:46 AM |
Crash while batch converting epubs under windows | AprilHare | Calibre | 3 | 04-26-2009 03:46 AM |