View Full Version : PRC to MOBI


wallcraft
12-30-2007, 10:28 AM
Almost all MobiPocket e-books come with the filename extension .prc, but this simply identifies a generic PalmOS compatible file (see PDB (http://wiki.mobileread.com/wiki/PDB) in the wiki). As the wiki says, PRC/PDB files have an 8 character plain text ID near the start viewable with any text editor. Older MobiPocket files, and those (e.g. from Baen) identified as MobiPocket/Palm, are TEXtREAd files but newer ones are BOOKMOBI. Note that either type can come with the filename extension .prc or .mobi, but I will call TEXtREAd files PRC and BOOKMOBI files MOBI.

All this matters because MOBI files have much richer metadata than PRC files. In particular MOBI files can include the author and the title and a cover image and a thumbnail image. This allows them to be handled differently by MobiPocket's Reader software under Windows and on three E-Ink readers (iLiad, Cybook and Kindle). It may also make a difference on other MobiPocket compatible devices. One simple way to identify PRC files it to look in MobiPocket's library view and see if an author is identified - if not it is a PRC.

Tompe's Mobiperl (http://www.mobileread.com/forums/showthread.php?t=17718) suite of command line programs manipulates DRM-free MOBI/PRC files. It includes the command mobi2mobi (http://www.ida.liu.se/~tompe/mobiperl/mobi2mobi.html) that can convert a PRC to a MOBI, adding the missing metadata as it does so. Mobiperl is written in Perl and is therefore cross-platform, and it includes pre-built binaries for Windows machines. A link to the latest windows binaries and an example of a mobi2mobi command line is in Mobiperl post #65 (http://www.mobileread.com/forums/showpost.php?p=132961&postcount=65). The typical mobi2mobi usage is: mobi2mobi file.prc --outfile file.mobi --author "Last, First" --title "Book Title" --coverimage cover.jpg --addthumbnail cover.jpg All the arguments are optional, and in particular you can leave off the image arguments if you want. I have not tried this, but mobi2mobi will probably work on actual PalmDOC .prc files as well (not just MobiPocket's extended PRC version).

The command line is unfamiliar to many Windows users, and if someone wants to add a GUI wrapper to mobi2mobi that would be very useful. I'm not sure I use the command line optimally, but the way I do this is to first copy mobi2mobi.exe to the same directory as the PRC file. Then open a command window (START > All Programs > Accessories > Command Prompt). In the command window:

cd dirpath
mobi2mobi file.prc --outfile file.mobi --author "Last, First" --title "Book Title" --coverimage cover.jpg --addthumbnail cover.jpg

The full "dirpath" starts with a capital letter, e.g. C:\, and I usually get it by copying and pasting from the Address header of a windows open on that directory (in this case the PRC directory). Note that the arrow keys allow you to recall previous command lines and you can edit them to create modified commands.

One source of PRC files is BookDesigner, which has been used on most e-books in the Mobi/PRC Upload forum. For new books, I suggest following HarryT's procedure for making MOBI books using BD and MobiPocket's Creator software, see Tutorial - How to Create a MobiPocket eBook (http://www.mobileread.com/forums/showthread.php?t=17914). For existing BD PRC e-books, an alternative is to use mobi2mobi. This won't create a formal Table of Contents, but it will do everything else a MOBI book needs. The cover image from BD is often very small. The optional MOBI cover is typically a JPEG close to 800x600 in size. If you created the PRC file via BD, then you may already have a large image that can be converted to JPEG. If not, then mobi2html will extract the images from the PRC file and you can use any image program to increase its size and convert to JPEG (I use IrfanView (http://www.irfanview.com/)). If there is already a cover image in the PRC file, --coverimage will replace this with the larger JPEG. The --addthumbnail option will make a thumbnail that will be used in the library view on some devices.

HarryT
12-30-2007, 11:35 AM
but the way I do this is to first copy mobi2mobi.exe to the same directory as the PRC file.

If you plan on using it regularly, it's a lot better to put the program in a folder (say "c:\tools"), then go to Windows Control Panel, run the "System" application, go to the "Advanced" tab, click "Environment Variables", and add the name of the folder to the "Path" environment variable (it's a semi-colon separated list of folder names).

That way, the command will be available from any command prompt without having to copy any files around.

tompe
12-30-2007, 11:43 AM
The optional MOBI cover is typically a JPEG close to 800x600 in size. If you created the PRC file via BD, then you may already have a large image that can be converted to JPEG. If not, then mobi2html will extract the images from the PRC file and you can use any image program to increase its size and convert to JPEG (I use IrfanView (http://www.irfanview.com/)). If there is already a cover image in the PRC file, --coverimage will replace this with the larger JPEG. The --addthumbnail option will make a thumbnail that will be used in the library view on some devices.

For the Gen3 it seems that adding a cover image is enough but to get the library image i the desktop version you have to add a thumb nail image.

I suddenly realize I have forgotten to rescale the images so if you input an image larger than 64k it will not work so good. Also there is an issue with large images (600x800) smaller than 64k on the Gen3. I will add my rescaling code to the next version. It is a bit unfortunate that I have not yet found the bug in the generated files that forces me to shrink the images a bit (to 480x640) for them to work on the Gen3. I think I will prioritize this bug...

HarryT
12-30-2007, 11:51 AM
On one of my converted books (I forget which one, unfortunately), Mobigen gave a build warning that the file contained a record >64k, and that it probably wouldn't work on Palm devices as a result. It was fine on the Gen3, though.

tompe
12-30-2007, 01:09 PM
What I do is to change the images to jpg and change the quality (not the resolution) so that it fits 64K. And that seems to work in all other readers than the Gen3. For the Gen3 I have to shrink the image and now I shrink it to the width 480. And then it works on the Gen3. But I have example mobi files with images that are 600x800 that works on the Gen3 so there is some issue with the Mobi-file I generate. I spent an hour now seeing if I could solve the problem but I think I give up until I have more time available or I get some good idea of what to test.

So until I update Mobiperl you should use images with max width 480 for it to work on the Gen3. After the update the rescaling will be done automatically.

wallcraft
12-30-2007, 02:00 PM
I think images slightly smaller than 600x800 are probably best anyway, because they are not usually displayed full-screen. I was just repeating MobiPocket's own advice (600x800) for cover image size.

The limit on image file sizes is actually <63K, rather than <64K. I base this on two MobiPocket Forum threads: jpg which are equal in size get different sizes (http://www.mobipocket.com/forum/viewtopic.php?t=7232) and Images in the ebook (http://www.mobipocket.com/forum/viewtopic.php?t=6135). So this might be your problem. In any case, one thing you could try (on one of the buggy 600x800 image .mobi files and a Windows desktop) is mobi2html and then mobigen -jpeg. If the mobigen version works on the Cybook then why? If not, then perhaps it isn't a html2mobi issue but a bug on the Cybook.

tompe
12-30-2007, 03:55 PM
n any case, one thing you could try (on one of the buggy 600x800 image .mobi files and a Windows desktop) is mobi2html and then mobigen -jpeg. If the mobigen version works on the Cybook then why? If not, then perhaps it isn't a html2mobi issue but a bug on the Cybook.

The was actually a very good idea. It did not work with mobigen either. The Cybook hangs. So now i have a testcase using only mobigen that I can report to Bookeen.

I had mistakenly assumed that the mobi file that I got from MobiPockets web site and that worked with 600x800 images was produced by mobigen. Because I also tested to use gif instead of jpg and that did not work either. But now i know that it probably is a cybook bug or a mobigen bug.