![]() |
#1 |
reader
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,977
Karma: 5183568
Join Date: Mar 2006
Location: Mississippi, USA
Device: Kindle 3, Kobo Glo HD
|
Explode and Implode an ePub?
The ePub container is just a ZIP file with standard compression, except that the file mimetype must be first and must not be compressed.
So, to "explode" an .epub file all you need is any command or utility that extracts files from a ZIP. To "implode" (is there a better term for this?) it back to a .epub isn't quite as easy. Salty-horse provides a Unix command line "implode" procedure here. Since it is using Info-ZIP, something similar should work for the Windows command line and on a Mac. Is there a better 1-step, or GUI-based, method to do this? Note that the contents of an ePub are fairly rigidly defined, and an explode/implode tool does nothing to check the validity of the contents (I guess the implode could check that the mimetype file exists and had the right contents, or make one if there is none). As in salty-horse's example, it would be most useful when something is wrong with an existing DRM-free ePub and you want to fix it. |
![]() |
![]() |
![]() |
#2 |
speaking for myself
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 139
Karma: 2166
Join Date: Feb 2008
Location: San Francisco Bay Area
Device: PRS-505
|
On Windows, just create a "compressed folder" (built-in functionality of Explorer) and add mimetype file as a first step before everything else. It figures out automatically that it is too small to compress, so it adds it as is. Then add everything else.
The same may be true for other GUI Zip utilities. |
![]() |
![]() |
![]() |
#3 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,221
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Do any epub reading systems actually insist on the mimetype file being first?
|
![]() |
![]() |
![]() |
#4 | |
reader
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,977
Karma: 5183568
Join Date: Mar 2006
Location: Mississippi, USA
Device: Kindle 3, Kobo Glo HD
|
Quote:
For Linux, the following single command works: Code:
zip -vur Author_Title.epub mimetype * |
|
![]() |
![]() |
![]() |
#5 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,924
Karma: 19318370
Join Date: Sep 2008
Device: Kobo Clara 2E
|
Info-Zip actually checks if the "deflate" algorithm will reduce the file size. In the case of the mimetype file, it's too small for the algorithm to be efficient, so no compression is done.
It also removes duplicates from the file list (such as the case of "mimetype *"), and zips the files by order. All of those form a very nice trick. ![]() HOWEVER (and I just figured this out), this creates a non-standard epub file. ![]() The specification states: http://www.idpf.org/ocf/ocf1.0/download/ocf10.htm Quote:
The original in my post used the -X flag on the mimetype. That flag strips away the headers, and is what required by the spec. BTW, the commands were given to me by Hadrien Gardeur. I claim no credit. |
|
![]() |
![]() |
![]() |
#6 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,924
Karma: 19318370
Join Date: Sep 2008
Device: Kobo Clara 2E
|
Doh!
Code:
zip -Xvur Author_Title.epub mimetype * The zip command is verbose by default, and -u isn't needed for new files, so you can even make this shorter: Code:
zip -Xr Author_Title.epub mimetype * ![]() |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
explode - plucker to html | pruss | Other formats | 11 | 02-23-2013 10:55 PM |
Can Calibre explode a MobiPocket .prc file and then reassemble it? | cyberbaffled | Calibre | 1 | 06-15-2010 11:14 PM |
epub, ePub, EPUB, warum blos ePub? | flowoeB | Lounge | 5 | 11-27-2009 09:37 AM |