cbconvert

package module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2026 License: GPL-3.0 Imports: 38 Imported by: 2

README

CBconvert

Introduction

CBconvert is a Comic Book converter.

It can convert comics to different formats to fit your various devices.

screenshot

See more screenshots.

Features

  • reads CBR (RAR), CBZ (ZIP), CB7 (7Z), CBT (TAR), PDF, XPS, EPUB, MOBI, DOCX, PPTX and plain directory
  • saves processed files in ZIP archive format or TAR
  • images can be converted to JPEG, PNG, TIFF, WEBP, AVIF, JXL, or 4-Bit BMP (16 colors) image format
  • rotate, adjust brightness/contrast or grayscale images
  • resize filters (NearestNeighbor, Box, Linear, MitchellNetravali, CatmullRom, Gaussian, Lanczos)
  • export covers from comics
  • create thumbnails from covers by FreeDesktop specification

Download

Download the latest binaries from the releases.

Linux Flatpak is available at Flathub.

Compile

You must have CGO_ENABLED=1. Note that Go will disable cgo when cross-compiling.

Install to GOBIN (you can point GOBIN to e.g. /usr/local/bin or ~/.local/bin):

go install github.com/gen2brain/cbconvert/cmd/cbconvert@latest

For GUI app, check IUP requirements, and then install:

go install github.com/gen2brain/cbconvert/cmd/cbconvert-gui@latest

Build tags

  • extlib - use external libmupdf library
  • pkgconfig - enable pkg-config (used with extlib)

Using cbconvert in file managers to generate FreeDesktop thumbnails

Copy/install cbconvert cli binary to your PATH, create file ~/.local/share/thumbnailers/cbconvert.thumbnailer and paste contents from thumbnailer.

This is what it looks like in the PCManFM file manager:

thumbnails

Using command line app

Usage: cbconvert <command> [<flags>] [file1 dir1 ... fileOrDirN]


Commands:

  convert
    	Convert archive or document

    --profile
    	Load a saved GUI profile as defaults; explicit flags still override (default "")
    --width
    	Image width (default "0")
    --height
    	Image height (default "0")
    --fit
    	Best fit for required width and height (default "false")
    --no-upscale
    	Do not upscale images already smaller than the requested width/height (default "false")
    --dpi
    	Document rendering resolution in DPI (PDF, EPUB, etc.), 0 uses the default (300) (default "0")
    --format
    	Image format, valid values are jpeg, png, tiff, bmp, webp, avif, jxl (default "jpeg")
    --archive
    	Archive format, valid values are zip, tar (default "zip")
    --zip-level
    	ZIP compression level, 0 disables compression, 1-9 sets deflate level (1 fastest, 9 smallest), -1 uses the default (default "-1")
    --quality
    	Image quality (default "75")
    --effort
    	Encoder speed/effort, format-specific (webp method 0-6, avif speed 0-10, jxl effort 1-10), -1 uses the format default (default "-1")
    --lossless
    	Lossless compression (webp, avif, jxl), ignores quality (default "false")
    --combine
    	Combine all inputs into a single archive (default "false")
    --outfile
    	Output file name for --combine (default: first input + -combined) (default "")
    --filter
    	0=NearestNeighbor, 1=Box, 2=Linear, 3=MitchellNetravali, 4=CatmullRom, 5=Gaussian, 6=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")
    --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 "")
    --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")

  cover
    	Extract cover

    --profile
    	Load a saved GUI profile as defaults; explicit flags still override (default "")
    --width
    	Image width (default "0")
    --height
    	Image height (default "0")
    --fit
    	Best fit for required width and height (default "false")
    --no-upscale
    	Do not upscale images already smaller than the requested width/height (default "false")
    --dpi
    	Document rendering resolution in DPI (PDF, EPUB, etc.), 0 uses the default (300) (default "0")
    --format
    	Image format, valid values are jpeg, png, tiff, bmp, webp, avif (default "jpeg")
    --quality
    	Image quality (default "75")
    --effort
    	Encoder speed/effort, format-specific (webp method 0-6, avif speed 0-10, jxl effort 1-10), -1 uses the format default (default "-1")
    --lossless
    	Lossless compression (webp, avif, jxl), ignores quality (default "false")
    --filter
    	0=NearestNeighbor, 1=Box, 2=Linear, 3=MitchellNetravali, 4=CatmullRom, 5=Gaussian, 6=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")

  thumbnail
    	Extract cover thumbnail (freedesktop spec.)

    --profile
    	Load a saved GUI profile as defaults; explicit flags still override (default "")
    --width
    	Image width (default "0")
    --height
    	Image height (default "0")
    --fit
    	Best fit for required width and height (default "false")
    --no-upscale
    	Do not upscale images already smaller than the requested width/height (default "false")
    --dpi
    	Document rendering resolution in DPI (PDF, EPUB, etc.), 0 uses the default (300) (default "0")
    --filter
    	0=NearestNeighbor, 1=Box, 2=Linear, 3=MitchellNetravali, 4=CatmullRom, 5=Gaussian, 6=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")

  meta
    	CBZ metadata

    --cover
    	Print cover name (default "false")
    --comment
    	Print zip comment (default "false")
    --comment-body
    	Set zip comment (default "")
    --file-add
    	Add file to archive (default "")
    --file-remove
    	Remove file from archive (glob pattern, i.e. *.xml) (default "")

  version
    	Print version

Examples

  • Rescale images to 1200px for all supported files found in a directory with a size larger than 60MB:

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:

cbconvert --format bmp --outdir ~/comics /media/comics/Garfield/Garfield_01.pdf

BMP 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.

  • Extract covers to ~/covers dir for all supported files found in the directory, Lanczos algorithm is used for resizing:

cbconvert cover --outdir ~/covers --filter=7 /media/comics/GrooTheWanderer/

  • Convert all images to AVIF format:

cbconvert --format avif --quality 50 --width 1280 --outdir ~/comics /media/comics/Misc/

  • Combine several issues into a single archive:

cbconvert convert --combine --outfile Series.cbz --outdir ~/comics issue1.cbz issue2.cbr issue3.cb7

Quality settings

This table maps quality settings for JPEG to the respective AVIF and WEBP quality settings:

JPEG quality 50 60 70 80
AVIF quality 48 51 56 64
WEBP quality 55 64 72 82

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileType added in v1.2.0

func FileType(path string) string

FileType returns the detected archive container, document extension, or "DIR".

Types

type Converter added in v1.0.4

type Converter struct {
	// Options struct
	Opts Options
	// Current working directory
	Workdir string

	// Number of files
	Nfiles int
	// Index of the current file
	CurrFile int
	// Number of contents in archive/document
	Ncontents int
	// Index of current content
	CurrContent int32
	// Start function
	OnStart func()
	// Progress function
	OnProgress func()
	// Compress function
	OnCompress func()
	// Cancel function
	OnCancel func()
	// contains filtered or unexported fields
}

Converter type.

func New

func New(o Options) *Converter

New returns new converter.

func (*Converter) Cancel added in v1.0.4

func (c *Converter) Cancel()

Cancel cancels the operation.

func (*Converter) Combine added in v1.2.0

func (c *Converter) Combine(files []File) error

Combine merges multiple comic books into a single archive.

func (*Converter) Convert added in v1.0.4

func (c *Converter) Convert(file File) error

Convert converts a comic book.

func (*Converter) Cover added in v1.0.4

func (c *Converter) Cover(file File) error

Cover extracts cover.

func (*Converter) CoverPreview added in v1.2.0

func (c *Converter) CoverPreview(fileName string, fileInfo os.FileInfo, width, height int) (Image, error)

CoverPreview returns the cover fitted into width x height, skipping the output-codec round-trip.

func (*Converter) Files added in v1.0.4

func (c *Converter) Files(args []string) ([]File, error)

Files returns list of found comic files.

func (*Converter) Meta added in v1.0.4

func (c *Converter) Meta(fileName string) (any, error)

Meta manipulates with CBZ metadata.

func (*Converter) PageCount added in v1.2.0

func (c *Converter) PageCount(fileName string, fileInfo os.FileInfo) (int, error)

PageCount returns the number of pages (images) in a comic file, document or directory.

func (*Converter) Preview added in v1.0.4

func (c *Converter) Preview(fileName string, fileInfo os.FileInfo, width, height int) (Image, error)

Preview returns the cover as an image preview.

func (*Converter) PreviewPage added in v1.2.0

func (c *Converter) PreviewPage(fileName string, fileInfo os.FileInfo, page, width, height int) (Image, error)

PreviewPage returns the page-th image (0-based) as an image preview.

func (*Converter) Thumbnail added in v1.0.4

func (c *Converter) Thumbnail(file File) error

Thumbnail extracts thumbnail.

type File

type File struct {
	Name      string
	Path      string
	Root      string
	Stat      os.FileInfo
	SizeHuman string
}

File type.

type Image

type Image struct {
	Image     image.Image
	Width     int
	Height    int
	SizeHuman string
}

Image type.

type Options

type Options struct {
	// Image format, valid values are jpeg, png, tiff, bmp, webp, avif, jxl
	Format string
	// Archive format, valid values are zip, tar
	Archive string
	// ZIP compression level: -1 default, 0 store (no compression), 1-9 deflate (1 fastest, 9 smallest)
	ZipLevel int
	// JPEG image quality
	Quality int
	// Encoder speed/effort, format-specific: webp method 0-6, avif speed 0-10, jxl effort 1-10; -1 uses the format default
	Effort int
	// Combine all inputs into a single archive
	Combine bool
	// Lossless enables lossless compression (webp, avif, jxl), ignores quality
	Lossless bool
	// Image width
	Width int
	// Image height
	Height int
	// Best fit for required width and height
	Fit bool
	// Do not upscale images already smaller than the requested width/height
	NoUpscale bool
	// Document rendering resolution in DPI (PDF, EPUB, etc.); 0 uses the page's native resolution
	DPI int
	// 0=NearestNeighbor, 1=Box, 2=Linear, 3=MitchellNetravali, 4=CatmullRom, 5=Gaussian, 6=Lanczos
	Filter int
	// Do not convert the cover image
	NoCover bool
	// Do not convert images that have RGB colorspace
	NoRGB bool
	// Remove non-image files from the archive
	NoNonImage bool
	// Do not transform or convert images
	NoConvert bool
	// Add suffix to file baseNoExt
	Suffix string
	// Extract cover
	Cover bool
	// Extract cover thumbnail (freedesktop spec.)
	Thumbnail bool
	// CBZ metadata
	Meta bool
	// Version
	Version bool
	// ZIP comment
	Comment bool
	// ZIP comment body
	CommentBody string
	// Add file
	FileAdd string
	// Remove file
	FileRemove string
	// Output file
	OutFile string
	// Output directory
	OutDir string
	// Convert images to grayscale (monochromatic)
	Grayscale bool
	// Rotate images, valid values are 0, 90, 180, 270
	Rotate int
	// Adjust the brightness of the images, must be in the range (-100, 100)
	Brightness int
	// Adjust the contrast of the images, must be in the range (-100, 100)
	Contrast int
	// Process subdirectories recursively
	Recursive bool
	// Process only files larger than size (in MB)
	Size int
	// Hide console output
	Quiet bool
}

Options type.

func NewOptions

func NewOptions() Options

NewOptions returns default options.

func (Options) Args added in v1.2.0

func (o Options) Args() []string

Args returns the non-default options as cbconvert convert command-line flags.

Directories

Path Synopsis
cmd
cbconvert module
cbconvert-gui module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL