Fight for the Internet 1!

Friday, August 19, 2016

Fix Misaligned ePub Cover

Recently I had some ePub files that had misaligned tiny cover images. I wanted to correct this. Here's a really simple fix for many cases.

I use Calibre as my eBook reader, and it has an option to "Edit book", which will take you to the digital book file editor.

http://3.bp.blogspot.com/-BF7JJn_LKeI/UrQ0D3fAsmI/AAAAAAAAATg/7SZfRszejBA/s1600/edit_book_opening_window.png

Notice the panel on the left upper area, labeled File Browser. Usually the first file in this list is the Cover html page file. Also in the middle of the left column, an area labeled Images.

Automatically Recreating the Cover
If you have a copy of the book cover (which is trivially easy thanks to Google), I suggest you just delete the first titlepage.html cover file (or whatever it is called), and the related image file under the image section.

Then go to Menu: Tools --> Add cover.

Then import the cover image, and check the option to preserve the aspect ratio.


Manually Editing the Image Alignment
Double click to open it. You may see something similar to this:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta content="ABBYY FineReader 11" name="generator" />
  <link href="Court_of_all_Shamens_files/Court_of_all_Shamens.css" rel="stylesheet" type="text/css" />

  <title></title>
</head>

<body>
  <p><img alt="9785567648623" src="../Images/9785567648623.jpg" /><br />
</body>
</html>

The problem here is the image is just dropped into the document without any helpful formatting to make it full-sized. With a few tweaks in the code, you can make it much more aesthetically pleasing.

In the <head> section, add the <style> section:

<head>
...
    <style type="text/css">
@page {padding: 0pt; margin:0pt}
                        body { text-align: center; padding:0pt; margin: 0pt; }
    </style>
...
</head>


In the <body> section, just drop in this code snippet, but replace the src="" contents with the image file in your file. Example:

<body>
  <div>
    <svg xmlns="http://www.w3.org/2000/svg" height="100%" version="1.1" viewBox="0 0 316 532" width="100%" xmlns:xlink="http://www.w3.org/1999/xlink">
    <image height="532" width="316" xlink:href="../Images/9785567648623.jpg"></image>
    </svg>
  </div>
</body>

This should center and enlarge your cover image properly.

Wednesday, May 11, 2016

Firefox not recognizing googletalk plugins

I'm not sure if I can make this a full tutorial but this information is still useful for people.

Basically I'm running an instance of Firefox from a downloaded tar.gz file from the Mozilla website.

For some reason it wouldn't recognize the install system libraries for the  Googletalk plugin. So simply put, I did install the downloaded RPM from Google (or the DEB file if you are using Debian). And then I copies all the library *.so files to a folder in my home folder. Specifically this folder:

~/.mozilla/plugins

Just sharing in it helps anyone.

Thursday, May 5, 2016

Calibre Author and Title Sorting

So I quite like the eBook management program called Calibre. But it has a few bad defaults. It outputs titles in a weird name format saving to disk (and sometimes author names). And it sorts authors by default with last name first (even storing them as such). This is wrong.

To fix the author sorting (and author name output when saving to disk):

1) Start calibre
1) Go to Preferences -> Advanced -> Tweaks.
2) Use the search option to find: "Author sort name algorithm"
3) There will be a few panels, including an area with text you can input or edit. In this area, find the line which starts with: author_sort_copy_method. If it doesn't exist, then skip to step 5 and just add it.
4) Here you can change the author sorting algorithm. Above this text input area is a brief description of the accepted options. But changes are you want to use the word copy.
5) Set the line: author_sort_copy_method = 'copy'
6) Click the button to "Apply changes to this tweak"
7) Restart calibre. It will probably ask you to anyway.

Now the work begins. I hope you don't have a lot of authors.

8) Back in the main view of the program, there is a column with your authors listed by name. Right-click on an author. Choose 'Manage Authors'.
9) There will be a column simply named "Authors".
10) Go through the entire list and change every author to be in order you want. (You can do it bit by bit or all at once. It doesn't matter to press OK occasionally and repeat these steps.) To make an entry editable, double click it. You press enter when you are finished editing.
11) As you change the values in the "Authors" column, the value names in the column labeled "Author sort" will change.

Correct any of the author_sort values that are wrong in your mind. Calibre will sort by the value in that box, so it must make sense to you.

12) When you are done press OK. Calibre will resort all of your changes. This might take a while.

The authors displayed in the tag view and in the library pane should all change.

13) Repeat 8-12 until all authors are changed and all author_sort values are correct.
13) Lastly, select all your books in your library.
14) Press 'e' to open the bulk metadata edit dialog.
15) Check the box 'automatically set author sort'. DO NOT check/change any other box.
16) Press OK. Wait until done.


I'm just passing these instructions along for my own notes and reference. Credit for these originally goes to Chaley: http://www.mobileread.com/forums/showpost.php?p=1104427&postcount=3