01-21-2020, 04:21 AM | #1 |
Junior Member
Posts: 2
Karma: 10
Join Date: Dec 2019
Device: Kindle Oasis (2nd gen)
|
Lossless ePub to AZW3 conversion (or, KindleUnpack but in reverse)
I have a few AZW3 files that I have already tweaked to my liking, but I want to do some batch tweaks and split some of them. Both seem to be much easier to achieve by having the books in the ePub format, so my plan is to convert the books to ePub using KindleUnpack, apply the tweaks to exploded books and use ePubSplit to cut them up, then reconvert them back to AZW3.
KindleUnpack seems to be able to convert AZW3 to ePub while preserving the formatting, HTML structure, CSS class names, etc. - but is there a plugin that does the reverse? Or a set of Calibre conversion options that won't mess with the book? |
01-21-2020, 06:52 AM | #2 |
Resident Curmudgeon
Posts: 73,957
Karma: 128903250
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
When is an ePub lossy?
You have two choices. You can convert to KF8 using Calibre or you can use Kindlegen. Kindlegen will create a dual-format mobi and you can use Kindlegen to split into Mobi & KF8. Last edited by JSWolf; 01-21-2020 at 06:54 AM. |
Advert | |
|
01-21-2020, 07:16 AM | #3 | |
Junior Member
Posts: 2
Karma: 10
Join Date: Dec 2019
Device: Kindle Oasis (2nd gen)
|
Quote:
Either way, it seems like a roundtrip through KindleUnpack -> KindleGen -> KindleUnpack does exactly what I need. Thanks! |
|
01-21-2020, 07:56 AM | #4 | |
Not Quite Dead
Posts: 194
Karma: 654170
Join Date: Jul 2015
Device: Paperwhite 4; Galaxy Tab
|
Quote:
1) In Calibre, open your corrected AZW file and save the CSS rules in a convenient location. 2) Convert your AZW file to ePub and open the ePub for edit. 3) Open stylesheet, delete every style and paste saved rules into file. 4) Apply Calibre's "remove unused style rules" tool. Save. The last step, if done with "remove unused class attributes" checked, will clean the structure so it is the same as your original AZW3. Last edited by Brett Merkey; 01-21-2020 at 08:01 AM. |
|
01-21-2020, 09:09 AM | #5 |
Guru
Posts: 927
Karma: 1177583
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
|
I think there is a problem there. At least some classe's names won't match, and will be removed on the process, losing part of the formatting.
|
Advert | |
|
01-21-2020, 10:09 AM | #6 | ||
Not Quite Dead
Posts: 194
Karma: 654170
Join Date: Jul 2015
Device: Paperwhite 4; Galaxy Tab
|
Quote:
Quote:
Last edited by Brett Merkey; 01-21-2020 at 10:25 AM. |
||
01-21-2020, 01:39 PM | #7 | |
Guru
Posts: 927
Karma: 1177583
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
|
Quote:
This is the original style sheet: Spoiler:
Now, this is the new style sheet after the conversion: Spoiler:
The resulting css has a lot of classes called 'calibreXX', and some of the original names are lost. The XHTML files are now referring to this new names. So, if you just paste the old style sheet, and clean the unused rules/classes, all the rules mismatching the text will be deleted, and so will be the classes unused on the XHTML files. Information/formatting will be lost. |
|
01-21-2020, 01:44 PM | #8 | |
Running with scissors
Posts: 1,552
Karma: 14325282
Join Date: Nov 2019
Device: none
|
Quote:
|
|
01-21-2020, 02:01 PM | #9 | |
Not Quite Dead
Posts: 194
Karma: 654170
Join Date: Jul 2015
Device: Paperwhite 4; Galaxy Tab
|
Quote:
One thing I observe which is important: When I make a conversion from one editable format to the other, Calibre adds classes and various other bits to the HTML but does not wipe previous classes in the structure. For instance, if I have a class "first-para" to distinguish each first paragraph in a chapter (for styling the usual pseudo-elements), Calibre leaves that class in place but adds (usually) two other classes in addition, partitioning the various CSS rules across these classes by some criteria unknown to me. When I wipe out the new Calibre stylesheet, all that other stuff gets wiped from the HTML. We are back to my original clean HTML and original CSS from the format that was converted. Last edited by Brett Merkey; 01-21-2020 at 02:10 PM. |
|
01-21-2020, 02:11 PM | #10 | |
Guru
Posts: 927
Karma: 1177583
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
|
Quote:
Not the case here, as it can be seen on the example posted. |
|
01-21-2020, 02:23 PM | #11 |
Resident Curmudgeon
Posts: 73,957
Karma: 128903250
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
What I do is use KindleUnpack to shift from KF8 to ePub and then I have a look at the ePub in the editor if the ePub is OK enough, I'll run epubcheck to check for errors and then I'll fix the errors. If the KF8 is not good enough to shift, I'll do a conversion.
After that, I'll remove unused CSS and losslessly compress the images. I'll also rename the HTML files to something that makes sense. And from there, I'll do my usual cleaning up. |
01-21-2020, 02:29 PM | #12 | |
Not Quite Dead
Posts: 194
Karma: 654170
Join Date: Jul 2015
Device: Paperwhite 4; Galaxy Tab
|
Quote:
Last edited by Brett Merkey; 01-21-2020 at 02:50 PM. |
|
01-21-2020, 02:36 PM | #13 | |
Resident Curmudgeon
Posts: 73,957
Karma: 128903250
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
The suggestion to put back the original CSS and remove unused classes is going to screw with the eBook. |
|
01-21-2020, 02:40 PM | #14 |
Addict
Posts: 254
Karma: 2092424
Join Date: Oct 2011
Location: Arlington, TX
Device: Kindle PW4, Moon+ Reader on a cheap Android tablet
|
I've sometimes wanted the same thing as the OP - kindleunpack can "repackage" an azw3 as epub, but I don't know of anything that does the reverse. I've also wished the calibre ebook editor - which can edit both azw3 and epub - had a "save as" function, so you could start out editing one, save it, then "save as" the other. (I currently read azw3 on a PW4, but make sure everything in calibre is also saved as the equivalent epub just in case I decide to switch to an epub reader).
Anyway, I haven't been motivated to try to tackle a calibre plugin for this, so I just convert. |
01-21-2020, 02:46 PM | #15 | |
Resident Curmudgeon
Posts: 73,957
Karma: 128903250
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
AZW3 to EPUB conversion 2 columns | ctemple | Conversion | 1 | 01-27-2019 08:56 PM |
Failed Conversion from AZW3 to EPUB | marie44 | Conversion | 10 | 03-24-2015 10:59 PM |
Problem with conversion from AZW3 to ePub | Kaetrin | Conversion | 3 | 05-30-2013 04:57 AM |
Conversion from epub to azw3 | Joy736 | Conversion | 12 | 01-01-2013 11:00 AM |
Conversion Lossy or Lossless? | KrowNB | Conversion | 6 | 03-11-2011 08:31 AM |