View Single Post
Old 02-11-2008, 11:47 PM   #3
nrapallo
GuteBook/Mobi2IMP Creator
nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.
 
nrapallo's Avatar
 
Posts: 2,958
Karma: 2530531
Join Date: Dec 2007
Location: Toronto, Canada
Device: REB1200 EBW1150 Device: T1 NSTG iLiad_v2 NC Device: Asus_TF Next1 WPDN
New 'mobi2imp.pl' that will directly convert from mobipocket .prc to .IMP formats

In the Content Forum under the (sticky) Mobiperl thread started by tompe, you will find post #219 that enables you to directly convert from mobipocket .mobi/.prc to .IMP formats via a perl script based on tompe's 'mobi2html'.

This new perl script is named 'mobi2imp.pl' and is available as a windows executable, 'mobi2imp.exe'.

MOBI2IMP
A simple batch file called mobi2IMP.bat demonstrates how .IMP ebooks can be converted directly from mobipocket .mobi/.prc using the workhorse routine 'mobi2imp'. 'Mobi2imp' takes as input two mandatory parameters: 'MobiSource' and 'ExplodeDir' and three optional parameters: 'Category' 'Authorname' and 'Title'. If any of the parameters contain spaces, then quotes need to surround that parameter!

To run this manually, just:
Code:
perl mobi2imp.pl --verbose "Oliver Twist.prc" Oliver
or
Code:
c:\> mobi2imp.exe --verbose "Oliver Twist.prc" Oliver
After executing the sample batch file, the .IMP ebook is produced along with the .opf project file used internally. This file can later be loaded into eBook Publisher for further processing, if necessary.
Attached below is the 'mobi2imp.pl' code, 'mobi2imp.exe' as well as two sample conversions in the .zip file for anyone who wants to test it out.

You must have the eBook Publisher software previously installed as well as the proper perl lib setup**. This will allow those with many mobipocket .mobi/.prc files to migrate them to their ebookwise 1150 easily.
Note: ** using 'mobi2imp.pl' requires a tricky setup as I used, as a base, the 'Mobiperl' package prepared by tompe (see his website http://www.ida.liu.se/~tompe/mobiperl/ for detailed setup instructions).

While it is daunting getting all the right libs, it is now very rewarding that it's setup properly. After all this SETUP, it is easy. I promise!
This all started out at post #197 in the Mobiperl thread and has evolved into a functional perl script.

For a MINI-TUTORIAL, check here.

For the Mobi2imp Wiki, check here.


Enjoy!

-Nick
Previous changes...
Code:
version 2 - Now 'Category Author Title' are optional and don't need to be provided (if the mobipocket ebook was 'well' composed).

version 3 - Now more forgiving of poorly constructed anchors (seen in feedbooks.com .prc's) and will insert the '<a name' tag as long as the 'filepos' points to the start of a tag i.e. "<".  This will help retain most, if not, all hyperlinks!

version 4 - Things that changed:
- Now better warns that eBook Publisher must be installed first.
- now takes switches '--1200' and '--1100' to allow for the simultaneous creation of the REB 1200 and REB 1100 versions along with the EBW 1150 .IMP version.
- conversly, if the switch '--1150' is specified, then the EBW 1150 .IMP version is NOT created.

version 5 - Things that are allowed now:
-  now allows you to change the text one font size larger ('medium') and one font size smaller (back to 'x-small') by using '--largerfont' and '--smallerfont' respectively.
-  per JSWolf's request, you can now change margins from the default (2%) to '--nomargins' (0%), '--largemargins' (5%)  and even '--hugemargins' (8%)
-  you can change the default text-align from justify to '--nojustify' (i.e. left aligned).
-  further to Kovidgoyal's recent 'mobi2oeb' post, now can output in OEBFF (.oeb) output with '--oeb'.
As a result, the output can be any and all at once of: '--1150' .IMP, '--1200' .IMP, '--1100' .rb and '--oeb' OEBFF!

version 6 - Changes:
-  per DaleDe's request, you can now change margins from the default (2%) to '--tinymargins' (2px).
-  no longer requires external program (nconvert.exe); all image 'fixing' done internally by GD.pm (thanks to tompe for this suggestion)!

version 7 - Changes:
-  per DaleDe's suggestion, you can now add small indent with '--indent'.
-  per JSWolf's request, you can now eliminate (blank line) paragraph separation with '--nopara' (may also need to indent para with '--indent').
-  per DaleDe's suggestion, you can now get more info with '--verbose' or '--debug'.
-  first attempt at a 'readme.txt' - you get this also by executing 'mobi2imp' without any paramenters.

version 8 - Changes:
- can now override default .IMP naming of 'Author - Title'.ext, by using '--out MYIMPBOOKNAME' to specify .IMP filename produced (omit .ext)  
-  BUGFIX: now strip <body> tag of any BD/mobi specific in-line styles before start 'fixing' things.[/SIZE]

EDIT 21 Feb 2008: version 9 - Changes:
- mobi2imp.exe (version 9) - windows executable (very stable now!)
- can now handle (text) .pdb files properly i.e. ereader 'TEXt'/'REAd' type
- now makes the BookDesigner notice at the end 'small print' by default :thumbsup:
- can make that BD notice 'big print' with '--BDbig' (case sensitive)
- can make that BD notice start on a newpage using '--BDnewpage' :2thumbsup
- can even remove that BD notice at the end with '--BDremove' :eek:
- to add flare, can use '--bgcolor #FF80FF' to set background color for every page
-  BUGFIX: Only when using '--nopara' option, some <br />'s get ignored so another <br /> is added;  if this creates issues, then '--noBRfix' will not add the second <br />.
TO DO:
- better documentation and even a tutorial would be nice
- ability to add a (default) 'cover' image to every conversion from .mobi to .imp exists, but not yet ready for the consequences
- ability to add running headers (ala GEBLibraian) exists, but not yet fully implemented
- add more user defined settings along with some 'Mobiperl' fixes like TOC first, cover link, prefix title...
- add Windows GUI ala PDFRead 1.8

EDIT: For a new GUI based Mobi2IMP with many improvements, see Mobi2IMP 9.4 with new Windows GUI & UTF-8
Attached Files
File Type: zip mobi2imp-exe.zip (1.57 MB, 870 views)
File Type: pl mobi2imp.pl (25.7 KB, 522 views)
File Type: bat mobi2IMP.bat (1.8 KB, 849 views)
File Type: zip mobi2imp_sample_conversions.zip (4.91 MB, 813 views)
File Type: txt Readme.txt (2.1 KB, 503 views)

Last edited by nrapallo; 10-18-2008 at 07:39 AM. Reason: link to new version 9.4 added
nrapallo is offline   Reply With Quote