Big update

This commit is contained in:
Milan Nikolic
2022-09-05 18:03:58 +02:00
parent 6a73f6f20e
commit cda03e0122
11 changed files with 1249 additions and 1004 deletions

281
README.md
View File

@@ -1,184 +1,171 @@
CBconvert
=========
## CBconvert
Introduction
------------
### Introduction
CBconvert is a [Comic Book](http://en.wikipedia.org/wiki/Comic_Book_Archive_file) converter written in [Go language](https://golang.org/).
CBconvert is a [Comic Book](http://en.wikipedia.org/wiki/Comic_Book_Archive_file) converter.
It can convert one comic at a time or bulk convert comics to different formats to fit your various devices.
It can convert comics to different formats to fit your various devices.
![screenshot](https://goo.gl/AxsWsA)
### Features
Features
--------
 - reads RAR, ZIP, 7Z, CBR, CBZ, CB7, CBT, PDF, EPUB, and plain directory
 - always saves processed comics in CBZ (ZIP) archive format
 - images can be converted to JPEG, PNG, TIFF, WEBP, or 4-Bit BMP (16 colors) file format
 - rotate, flip, adjust brightness/contrast, adjust levels (Photoshop-like) or grayscale images
 - resize algorithms (NearestNeighbor, Box, Linear, MitchellNetravali, CatmullRom, Gaussian, Lanczos)
 - export covers from comics
 - create thumbnails from covers by [FreeDesktop](http://www.freedesktop.org/wiki/) specification
- reads RAR, ZIP, 7Z, GZ, BZ2, CBR, CBZ, CB7, CBT, PDF, EPUB, XPS and plain directory
- always saves processed comic in CBZ (ZIP) archive format
- images can be converted to JPEG, PNG, GIF, TIFF or 4-Bit BMP (16 colors) file format
- rotate, flip, adjust brightness/contrast, adjust levels (Photoshop like) or grayscale images
- choose resize algorithm (NearestNeighbor, Box, Linear, MitchellNetravali, CatmullRom, Gaussian, Lanczos)
- export covers from comics
- create thumbnails from covers by [freedesktop](http://www.freedesktop.org/wiki/) specification
### Download
Download
--------
 - [Windows](https://github.com/gen2brain/cbconvert/releases/download/0.7.0/cbconvert-0.7.zip)
 - [Linux](https://github.com/gen2brain/cbconvert/releases/download/0.7.0/cbconvert-0.7.tar.gz)
- [Windows GUI](https://github.com/gen2brain/cbconvert/releases/download/0.6.0/cbconvert-0.6.zip)
- [Windows CMD](https://github.com/gen2brain/cbconvert/releases/download/0.6.0/cbconvert-cmd-0.6.zip)
### Using cbconvert in file managers to generate FreeDesktop thumbnails
- [Linux 64bit GUI](https://github.com/gen2brain/cbconvert/releases/download/0.6.0/cbconvert-0.6.tar.gz)
- [Linux 64bit CMD](https://github.com/gen2brain/cbconvert/releases/download/0.6.0/cbconvert-cmd-0.6.tar.gz)
Copy cbconvert cli binary to your PATH and create file ~/.local/share/thumbnailers/cbconvert.thumbnailer :
   
    [Thumbnailer Entry]
    TryExec=cbconvert
    Exec=cbconvert thumbnail --quiet --width %s --outfile %o %i
    MimeType=application/pdf;application/x-pdf;image/pdf;application/x-cbz;application/x-cbr;application/x-cb7;application/x-cbt;application/epub+zip;
Using cbconvert in file managers to generate freedesktop thumbnails
-------------------------------------------------------------------
This is what it looks like in the PCManFM file manager:
Just copy cbconvert cmd binary to your PATH and create file ~/.local/share/thumbnailers/cbconvert.thumbnailer :
[Thumbnailer Entry]
TryExec=cbconvert
Exec=cbconvert thumbnail --quiet --width %s --outfile %o %i
MimeType=application/pdf;application/x-pdf;image/pdf;application/x-cbz;application/x-cbr;application/x-cb7;application/x-cbt;application/oxps;application/vnd.ms-xpsdocument;application/epub+zip;
This is how it looks like in PCManFM file manager:
![thumbnails](https://goo.gl/I39Otm)
![thumbnails](https://bit.ly/3BaTvTV)
Using command line app
----------------------
### Using command line app
usage: cbconvert [<flags>] <command> [<args> ...]
Comic Book convert tool.
Flags:
--help Show context-sensitive help (also try --help-long and --help-man).
--version Show application version.
--outdir="." Output directory
--size=0 Process only files larger then size (in MB)
--recursive Process subdirectories recursively
--quiet Hide console output
Args:
<args> filename or directory
Commands:
help [<command>...]
Show help.
    Usage: cbconvert <command> [<flags>] [file1 dir1 ... fileOrDirN]
convert [<flags>] <args>...
Convert archive or document (default command)
    Commands:
--width=0 Image width
--height=0 Image height
--fit Best fit for required width and height
--format="jpeg" Image format, valid values are jpeg, png, gif, tiff, bmp
--quality=75 JPEG image quality
--filter=2 0=NearestNeighbor, 1=Box, 2=Linear, 3=MitchellNetravali, 4=CatmullRom, 6=Gaussian, 7=Lanczos
--cover Convert cover image (use --no-cover if you want to exclude cover)
--rgb Convert images that have RGB colorspace (use --no-rgb if you only want to convert grayscaled images)
--nonimage Leave non image files in archive (use --no-nonimage to remove non image files from archive)
--grayscale Convert images to grayscale (monochromatic)
--rotate=0 Rotate images, valid values are 0, 90, 180, 270
--flip="none" Flip images, valid values are none, horizontal, vertical
--brightness=0 Adjust brightness of the images, must be in range (-100, 100)
--contrast=0 Adjust contrast of the images, must be in range (-100, 100)
--suffix=SUFFIX Add suffix to file basename
--levels-inmin=0 Shadow input value
--levels-inmax=255 Highlight input value
--levels-gamma=1 Midpoint/Gamma
--levels-outmin=0 Shadow output value
--levels-outmax=255 Highlight output value
      convert*
            Convert archive or document (default command)
cover [<flags>] <args>...
Extract cover
        --width
            Image width (default "0")
        --height
            Image height (default "0")
        --fit
            Best fit for required width and height (default "false")
        --format
            Image format, valid values are jpeg, png, tiff, bmp, webp (default "jpeg")
        --quality
            JPEG image quality (default "75")
        --filter
            0=NearestNeighbor, 1=Box, 2=Linear, 3=MitchellNetravali, 4=CatmullRom, 6=Gaussian, 7=Lanczos (default "2")
        --no-cover
            Do not convert the cover image (default "false")
        --no-rgb
            Do not convert images that have RGB colorspace (default "false")
        --no-nonimage
            Remove non-image files from the archive (default "false")
        --no-convert
       Do not transform or convert images (default "false")
        --grayscale
            Convert images to grayscale (monochromatic) (default "false")
        --rotate
            Rotate images, valid values are 0, 90, 180, 270 (default "0")
        --flip
            Flip images, valid values are none, horizontal, vertical (default "none")
        --brightness
            Adjust the brightness of the images, must be in the range (-100, 100) (default "0")
        --contrast
            Adjust the contrast of the images, must be in the range (-100, 100) (default "0")
        --suffix
            Add suffix to file basename (default "")
        --levels-inmin
            Shadow input value (default "0")
        --levels-gamma
            Midpoint/Gamma (default "1")
        --levels-inmax
            Highlight input value (default "255")
        --levels-outmin
            Shadow output value (default "0")
        --levels-outmax
            Highlight output value (default "255")
        --outdir
            Output directory (default ".")
        --size
            Process only files larger than size (in MB) (default "0")
        --recursive
            Process subdirectories recursively (default "false")
        --quiet
            Hide console output (default "false")
--width=0 Image width
--height=0 Image height
--fit Best fit for required width and height
--quality=75 JPEG image quality
--filter=2 0=NearestNeighbor, 1=Box, 2=Linear, 3=MitchellNetravali, 4=CatmullRom, 6=Gaussian, 7=Lanczos
      cover
            Extract cover
thumbnail [<flags>] <args>...
Extract cover thumbnail (freedesktop spec.)
        --width
            Image width (default "0")
        --height
            Image height (default "0")
        --fit
            Best fit for required width and height (default "false")
        --quality
            JPEG image quality (default "75")
        --filter
            0=NearestNeighbor, 1=Box, 2=Linear, 3=MitchellNetravali, 4=CatmullRom, 6=Gaussian, 7=Lanczos (default "2")
        --outdir
            Output directory (default ".")
        --size
            Process only files larger than size (in MB) (default "0")
        --recursive
            Process subdirectories recursively (default "false")
        --quiet
            Hide console output (default "false")
--width=0 Image width
--height=0 Image height
--fit Best fit for required width and height
--filter=2 0=NearestNeighbor, 1=Box, 2=Linear, 3=MitchellNetravali, 4=CatmullRom, 6=Gaussian, 7=Lanczos
      thumbnail
            Extract cover thumbnail (freedesktop spec.)
[man page](https://en.wikipedia.org/wiki/Man_page) is also available:
        --width
            Image width (default "0")
        --height
            Image height (default "0")
        --fit
            Best fit for required width and height (default "false")
        --filter
            0=NearestNeighbor, 1=Box, 2=Linear, 3=MitchellNetravali, 4=CatmullRom, 6=Gaussian, 7=Lanczos (default "2")
        --outdir
            Output directory (default ".")
        --outfile
            Output file (default "")
        --size
            Process only files larger than size (in MB) (default "0")
        --recursive
            Process subdirectories recursively (default "false")
        --quiet
            Hide console output (default "false")
cbconvert --help-man | man /dev/stdin
### Examples
Examples
--------
Rescale images to 1200px for all supported files found in a directory with a size larger than 60MB:
Rescale images to 1200px for all supported files found in directory with size larger then 60MB:
    cbconvert --recursive --width 1200 --size 60 /media/comics/Thorgal/
cbconvert --recursive --width 1200 --size 60 /media/comics/Thorgal/
Convert all images in pdf to 4bit BMP images and save the result in ~/comics directory:
Convert all images in pdf to 4bit BMP image and save result in ~/comics directory:
    cbconvert --bmp --outdir ~/comics /media/comics/Garfield/Garfield_01.pdf
cbconvert --bmp --outdir ~/comics /media/comics/Garfield/Garfield_01.pdf
[BMP](http://en.wikipedia.org/wiki/BMP_file_format) format is a very good choice for black&white pages. Archive size can be smaller 2-3x and the file will be readable by comic readers.
[BMP](http://en.wikipedia.org/wiki/BMP_file_format) format is very good choice for black&white pages. Archive size can be smaller 2-3x and file will be readable by comic readers.
Generate thumbnails by [freedesktop specification](http://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html) in ~/.cache/thumbnails/normal directory with width 512:
Generate thumbnails by [freedesktop specification](http://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html) in ~/.thumbnails/normal directory with width 512:
    cbconvert thumbnail --width 512 --outdir ~/.cache/thumbnails/normal /media/comics/GrooTheWanderer/
cbconvert thumbnail --width 512 --outdir ~/.thumbnails/normal /media/comics/GrooTheWanderer/
Extract covers to ~/covers dir for all supported files found in the directory, Lanczos algorithm is used for resizing:
Extract covers to ~/covers dir for all supported files found in directory, Lanczos algorithm is used for resizing:
    cbconvert cover --outdir ~/covers --filter=7 /media/comics/GrooTheWanderer/
cbconvert cover --outdir ~/covers --filter=7 /media/comics/GrooTheWanderer/
### Compile
Compile
-------
Install ImageMagick development packages, e.g. on Ubuntu:
Install imagemagick dev packages:
    apt-get install libmagickcore-dev libmagickwand-dev
apt-get install libmagickcore-dev libmagickwand-dev
Install to GOBIN:
Compile latest MuPDF:
git clone git://git.ghostscript.com/mupdf.git && cd mupdf
git submodule update --init --recursive
curl -L https://gist.githubusercontent.com/gen2brain/7869ac4c6db5933f670f/raw/1619394dc957ae10bcd73c713760993466b4bfea/mupdf-openssl-curl.patch | patch -p1
sed -e "1iHAVE_X11 = no" -e "1iWANT_OPENSSL = no" -e "1iWANT_CURL = no" -i Makerules
HAVE_X11=no HAVE_GLFW=no HAVE_GLUT=no WANT_OPENSSL=no WANT_CURL=no HAVE_MUJS=yes HAVE_JSCORE=no HAVE_V8=no make && make install
Compile unarr library:
git clone https://github.com/zeniko/unarr && cd unarr
mkdir lzma920 && cd lzma920 && curl -L http://www.7-zip.org/a/lzma920.tar.bz2 | tar -xjvp && cd ..
curl -L http://zlib.net/zlib-1.2.8.tar.gz | tar -xzvp
curl -L http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz | tar -xzvp
curl -L https://gist.githubusercontent.com/gen2brain/89fe506863be3fb139e8/raw/8783a7d81e22ad84944d146c5e33beab6dffc641/unarr-makefile.patch | patch -p1
CFLAGS="-DHAVE_7Z -DHAVE_ZLIB -DHAVE_BZIP2 -I./lzma920/C -I./zlib-1.2.8 -I./bzip2-1.0.6" make
cp build/debug/libunarr.a /usr/lib64/ && cp unarr.h /usr/include
Install dependencies:
go get github.com/cheggaaa/pb
go get github.com/disintegration/imaging
go get github.com/gen2brain/go-fitz
go get github.com/gen2brain/go-unarr
go get github.com/gographics/imagick/imagick
go get github.com/hotei/bmp
go get github.com/skarademir/naturalsort
go get golang.org/x/image/tiff
go get golang.org/x/image/webp
go get gopkg.in/alecthomas/kingpin.v2
For command line app:
go get github.com/gen2brain/cbconvert
go build -o $GOPATH/bin/cbconvert github.com/gen2brain/cbconvert/cmd
For GUI app:
go get gopkg.in/qml.v1
go get github.com/gen2brain/cbconvert
go build -o $GOPATH/bin/cbconvert github.com/gen2brain/cbconvert/gui
    go install github.com/gen2brain/cbconvert/cmd/cbconvert@latest