janeczku / calibre-web

:books: Web app for browsing, reading and downloading eBooks stored in a Calibre database
GNU General Public License v3.0
12.84k stars 1.36k forks source link

Blank margins in comics downloaded via kobosync #1514

Closed AntonioDeTeo closed 7 months ago

AntonioDeTeo commented 4 years ago

Hi!, This is a strange problem: I have comics in cbr/cbz format and I've converted them to epub format so they can be downloaded via kobosync, but comics downloaded by this method show a white margin (except for the cover, which is shown at full screen), so the screen is not fully used. Those same epubs, if I load them into my kobo using the windows Calibre application or directly copy them to the root of the device, they look fine without margins. I don't know if it's possible to solve this from calibre-web or it's a kobo firmware problem that can't be fixed. I have also tried to download them in kepub format and the result is the same.

I've tried it on a kobo libra H2O and a kobo forma.

Any idea to solve this? Does it happen to anyone else?

ATD555 commented 4 years ago

Kobo uses the CBZ/CBR format for reading comics. What happens if you keep it as CBZ/CBR format?

AntonioDeTeo commented 4 years ago

Hello, the point is that to download the comics using the kobosync functionality, the comics have to be in epub or kepub format. If they are not in some of those formats, they are ignored and not available for download by this method. If I copy the comics in cbz/cbr/epub format directly via usb cable to my kobo device, I have no problem and they look good without white borders. The strange thing is that exactly the same comic (in epub format) if I download it using kobosync functionality, these margins appear and if I copy it directly from the pc to the device it looks without margins.

OzzieIsaacs commented 3 years ago

Most likely related to #1219 and hard (if not impossible) to fix, as kobo device handles both ways of putting a book onto the device different.

manzaloros commented 2 years ago

Just wanted to jump in and confirm that I have the same issue.

When loading a manga / comic directly onto the kobo with usb, there are no margins and the images are viewed full screen. When loading the same epub via kobo sync on Calibre Web, there are annoying white margins. At first I thought this was because kobosync was automatically converting the epubs to kepubs when sending over Kobo sync, and the kepub will always have white margins, but I’m not sure about that.

SpykerNZ commented 1 year ago

I have encountered the same issue.

If I copy the epub directly to my kobo via usb then there are no margins. If I use kobosync, then the white margins appear. During this sync the file is converted to a kepub.

As @manzaloros mentioned it might be the conversion to kepub causing this. Would there be a way to force sync as an epub?

vivaria commented 12 months ago

Hi folks! I was also encountering this issue, and found one way of solving it:

Before / After ![IMG_20231022_141151](https://github.com/janeczku/calibre-web/assets/76574898/6d0185eb-a21c-467a-9d86-dda77d674e16) ![IMG_20231022_143623](https://github.com/janeczku/calibre-web/assets/76574898/e659afb3-ec59-4537-9ffd-c6dc888ddd9e)

The key is PR #2262, merged on Feb 27, 2023 and included in releases v0.6.20 and above. It detects what are called "Fixed Layout EPUBs" from EPUB metadata, and sets the correct EPUB format accordingly.

However, for this to work, your comic/manga files have to actually have the correct "Fixed Layout EPUB" metadata. Importantly, the default Calibre "CBZ -> EPUB" conversion settings do not set the correct metadata, likely because Calibre is mainly designed for text-based books, prioritizing the "reflowable" EPUB format.

Calibre's lack of Fixed Layout EPUB support is out of scope for the calibre-web project. But, here are some solutions for updating your converted CBZ->EPUB files to work with PR #2262:

Updating existing books (1 at a time)

This is a bit tedious to do, but it helps explain precisely what is going on, step by step:

Updating existing books (automated)

It's fairly easy to automatically perform these steps using something like a bash script (source):

#!/bin/bash

# WARNING: You don't want to accidentally set this for regular EPUBs in your library, so tread carefully!
# This script also presumes you have access to Linux CLI tools such as sed/mktemp/pushd/zip/etc.

insert_fixed_metadata() {
  epub=$1
  tmp_epub=$(mktemp -d)
  unzip -q "$epub" -d $tmp_epub
  pushd $tmp_epub > /dev/null
  if grep -q "pre-paginated" "content.opf"; then
    echo "Skipping $epub (already contains pre-paginated metadata)"
  else
    echo "Adding pre-paginated metadata to $epub"
    CONTENT='\t\t<meta property="rendition:layout" scheme="dcterms:W3CDTF">pre-paginated</meta>'
    sed -i '/<\/metadata>/i\'"$CONTENT" content.opf
    zip -q -r "$epub" * -x mimetype
  fi
  pushd > /dev/null
  rm -rf $tmp_epub
}
export -f insert_fixed_metadata

echo "Looking for epub/kepub files in $1"
find "$1" -name "*.epub" -or -name "*.kepub" -type f | xargs -I {} bash -c 'insert_fixed_metadata "$@"' _ {}

You would save this as, say, "set_fixedlayout_books.sh" then execute it by running ./set_fixedlayout_books.sh ./PATH/TO/EPUB/FOLDER. Then, after all of the files are updated, force a resync as described in the "1 book at a time" section. (I don't have a good solution for automatically removing then re-adding all of the existing books in calibre-web, though. 😅)

This script should also work for CBZ files that have been converted to EPUB, but not yet synced? (That way you don't have to do the whole delete-readd-resync steps.)

OzzieIsaacs commented 7 months ago

Fixed in 0.6.20