Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 07-06-2009, 06:15 AM   #1
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 6,258
Karma: 4801165
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Mobi -> Mobi "conversion"

Hello,

I have a mobipocket file that has every paragraph with hard-coded left alignment, and I'd like to change it and remove the explicit alignment. I don't want to change anything else in the file (metadata, etc.). What would be the best way to achieve this?

After trying unsuccessfully with MobiPerl I managed to install Calibre, and tried with mobi2oeb, edit the .html, and oeb2mobi, but something is not fine here:

1. The original .mobi file is 2.6MB, the converted one is 1.6MB

2. The converted file adds vertical space above every paragraph. Indeed, when I convert again this new file to oeb, the .html file has "margin-top: 1em" for every paragraph, which was not present initially.

3. The original language (according to mobi-meta) is ENGLISH, the language of the converted file is NEUTRAL

So, suggestions or advice for altering only the text in the mobipocket file and in a controlled way?

EDIT: I've tried with version 0.5.11, by the way.

Last edited by Jellby; 07-06-2009 at 07:06 AM.
Jellby is online now   Reply With Quote
Old 07-06-2009, 07:19 AM   #2
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 37,836
Karma: 18755150
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Sony Reader PRS-650, iPad, nook STR
Try mobi2oeb and then edit the HTML and try rebuilding it backinto a Mobipocket format eBook.
JSWolf is offline   Reply With Quote
 
Advertisement
Old 07-06-2009, 07:39 AM   #3
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 6,258
Karma: 4801165
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by JSWolf View Post
Try mobi2oeb and then edit the HTML and try rebuilding it backinto a Mobipocket format eBook.
That's what I did, or I don't quite understand... I said I "tried with mobi2oeb, edit the .html, and oeb2mobi, but something is not fine here"
Jellby is online now   Reply With Quote
Old 07-06-2009, 08:05 AM   #4
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 37,836
Karma: 18755150
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Sony Reader PRS-650, iPad, nook STR
Is this file one you can attach here?
JSWolf is offline   Reply With Quote
Old 07-06-2009, 08:12 AM   #5
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 6,258
Karma: 4801165
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
No, sorry
Jellby is online now   Reply With Quote
Old 07-06-2009, 08:40 AM   #6
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 6,258
Karma: 4801165
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
... but I can post this one, which shows similar problems.

a.mobi is just my Mobipocket version of "The Picture of Dorian Gray". It was created with MobiPerl's html2mobi, from a mobi-flavoured HTML (no mobipocket creator involved).

a-dir is what resulted from
Code:
mobi2oeb a.mobi -o a-dir
b.mobi is the result of
Code:
oeb2mobi a-dir/The\ Picture\ of\ Dorian\ Gray.opf -o b.mobi
b-dir is the result of
Code:
mobi2oeb b.mobi -o b-dir
I expected a.mobi and b.mobi to be almost the same, but a.mobi is 322KB and b.mobi 548KB.

I also expected a-dir and b-dir to have very similar contents, but not even the images are the same (they have different sizes). And the HTML in a-dir has simple <p>...</p> tags, while the one in b-dir has <p style="margin-top: 1em; text-indent: 0pt; text-align: justify">...</p>
Attached Files
File Type: zip test.zip (904.3 KB, 128 views)
Jellby is online now   Reply With Quote
Old 07-06-2009, 11:23 AM   #7
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: 26,329
Karma: 5382313
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Don't use oeb2mobi, use any2mobi on the OPF file. Also make sure you have justification turned off.
kovidgoyal is offline   Reply With Quote
Old 07-06-2009, 12:09 PM   #8
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 6,258
Karma: 4801165
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by kovidgoyal View Post
Don't use oeb2mobi, use any2mobi on the OPF file. Also make sure you have justification turned off.
I tried this:

Code:
any2mobi --no-justification -o b.mobi a-dir/The\ Picture\ of\ Dorian\ Gray.opf
(after deleting the justification from the <style> and <body> tags of the HTML in a-dir)

And the result is a bit better, but still:

1. b.mobi is quite larger than a.mobi
2. The images in both a-dir/images and b-dir/images are not the same size
3. The HTML in b-dir still has <p style="margin-top: 1em; text-indent: 0pt"> instead of simply <p>, which is cumbersome and "wrong" (I don't want explicit top margin or indent).
4. The language of b.mobi is NEUTRAL instead of ENGLISH

Wouldn't it be possible to have a couple of commands to just unpack and pack a mobi file with no data loss? (I admit I have no real knowledge of the internal structure of mobipocket format.)
Jellby is online now   Reply With Quote
Old 07-06-2009, 12:44 PM   #9
tompe
Grand Sorcerer
tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.
 
Posts: 7,129
Karma: 4315826
Join Date: Oct 2007
Location: Link÷png, Sweden
Device: Nexus 7, Nexus 5, iPad 2, Kindle PW
Quote:
Originally Posted by Jellby View Post
Wouldn't it be possible to have a couple of commands to just unpack and pack a mobi file with no data loss? (I admit I have no real knowledge of the internal structure of mobipocket format.)
MobiPerl tried to take this approach but I do not think it is perfect.

Calibre uses a totally different approach since it converts to a middle format and then have backends for the different output formats.
tompe is online now   Reply With Quote
Old 07-06-2009, 12:51 PM   #10
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 6,258
Karma: 4801165
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by tompe View Post
MobiPerl tried to take this approach but I do not think it is perfect.
Alas, no. For the particular mobi file I wanted to modify, it gave an empty html file, probably because of the compression.
Jellby is online now   Reply With Quote
Old 07-06-2009, 12:57 PM   #11
tompe
Grand Sorcerer
tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.
 
Posts: 7,129
Karma: 4315826
Join Date: Oct 2007
Location: Link÷png, Sweden
Device: Nexus 7, Nexus 5, iPad 2, Kindle PW
Quote:
Originally Posted by Jellby View Post
Alas, no. For the particular mobi file I wanted to modify, it gave an empty html file, probably because of the compression.
Yes, that is usually the reason.

One obvious feature of Calibre would be to just change the compression.
tompe is online now   Reply With Quote
Old 07-06-2009, 01:21 PM   #12
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: 26,329
Karma: 5382313
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Having specialised tools for every format quickly leads to insanity. Instead calibre takes the approach that you write your HTML once and it will do its best to render it as faithfully as possible in all the formats.

There is probably some CSS lurking around somewhere in your decompiled MOBI that's causing the margins. Try setting --override-css "p {margin-top: 0pt}"
kovidgoyal is offline   Reply With Quote
Old 07-06-2009, 01:47 PM   #13
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 6,258
Karma: 4801165
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by kovidgoyal View Post
Having specialised tools for every format quickly leads to insanity. Instead calibre takes the approach that you write your HTML once and it will do its best to render it as faithfully as possible in all the formats.
And I think that's a good approach. But my needs here are a bit different. I'm not trying to create a mobipocket file from my custom HTML, all I want is minimally change the HTML (or whatever) that is already in the mobipocket file. Maybe the mobipocket file has unsupported tags, or unclosed elements... but I don't care, I don't want them corrected (that's good in general, but that's not what I want now, I mean).

See, with ePUB is easy. I can unzip the .epub file, change "black" to "white" and zip everything again, and I don't care whether or not the XHTML validates or CSS classes are undefined. Well, I was thinking that it would be good to be able to do the same with mobipocket files, if you see what I mean.

Of course, it's your program and you do what you see fit I just thought that since there are already programs that can parse and create mobipocket files, it shouldn't be too hard to have a program that blindly unpacks and packs mobipocket files.

But anyway, I'm still confused that mobi->oeb->mobi->oeb generates such a "mess". Maybe the mobi->oeb conversion is more or less lossless, but then oeb->mobi tries to fix the HTML? I thougt that mobi->oeb would already fix things so that the subsequent oeb->mobi->oeb would be rather transparent.

Last edited by Jellby; 07-07-2009 at 05:44 AM.
Jellby is online now   Reply With Quote
Old 07-06-2009, 02:20 PM   #14
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: 26,329
Karma: 5382313
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I don't actually recall what mobi2oeb and oeb2mobi do (it's ages since I've used an 0.5 version of calibre) but at least mobi2oeb converts mobipocket markup to proper HTML and I believe (though I'm not sure) oeb2mobi converts HTMl to mobipocket markup
kovidgoyal is offline   Reply With Quote
Old 07-08-2009, 09:41 AM   #15
AlexBell
Wizard
AlexBell ought to be getting tired of karma fortunes by now.AlexBell ought to be getting tired of karma fortunes by now.AlexBell ought to be getting tired of karma fortunes by now.AlexBell ought to be getting tired of karma fortunes by now.AlexBell ought to be getting tired of karma fortunes by now.AlexBell ought to be getting tired of karma fortunes by now.AlexBell ought to be getting tired of karma fortunes by now.AlexBell ought to be getting tired of karma fortunes by now.AlexBell ought to be getting tired of karma fortunes by now.AlexBell ought to be getting tired of karma fortunes by now.AlexBell ought to be getting tired of karma fortunes by now.
 
AlexBell's Avatar
 
Posts: 2,319
Karma: 3943902
Join Date: May 2008
Location: Launceston, Tasmania
Device: Kindle3, Kobo Touch, Sony PRS T3, Nexus 7, iPad mini
Quote:
Originally Posted by kovidgoyal View Post
Having specialised tools for every format quickly leads to insanity. Instead calibre takes the approach that you write your HTML once and it will do its best to render it as faithfully as possible in all the formats.

There is probably some CSS lurking around somewhere in your decompiled MOBI that's causing the margins. Try setting --override-css "p {margin-top: 0pt}"
I must have missed the announcement that your thesis was accepted.

Congratulations!

Regards, Alex
AlexBell is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Transfer Web pages to Kindle - what do you use? "Print to MOBI" an option? guiyoforward Amazon Kindle 8 09-06-2010 01:50 AM
EPUB to MOBI: "Failed: Convert book 1 of 1" Jillo Introduce Yourself 4 02-20-2010 07:49 PM
Content Mobi Reference ("Huge Collections") on Kindle Mike L Amazon Kindle 26 04-28-2009 04:14 PM
"Secure" PDF and "Secure" Mobi docs? AceHarddrive iRex 9 05-08-2008 10:13 PM
New ".mobi" domain names are coming in May 2006 Bob Russell Lounge 3 04-25-2006 06:38 PM


All times are GMT -4. The time now is 04:49 PM.


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