mirror of
https://github.com/gen2brain/cbconvert
synced 2025-10-14 10:38:51 +02:00
rename interp. to resize
This commit is contained in:
@@ -42,13 +42,13 @@ Using
|
|||||||
-h, --height=0 image height
|
-h, --height=0 image height
|
||||||
-q, --quality=75 JPEG image quality
|
-q, --quality=75 JPEG image quality
|
||||||
-n, --norgb do not convert images with RGB colorspace
|
-n, --norgb do not convert images with RGB colorspace
|
||||||
-i, --interpolation=1 0=NearestNeighbor, 1=Bilinear, 2=Bicubic, 3=MitchellNetravali, 4=Lanczos2, 5=Lanczos3
|
-r, --resize=1 0=NearestNeighbor, 1=Bilinear, 2=Bicubic, 3=MitchellNetravali, 4=Lanczos2, 5=Lanczos3
|
||||||
-s, --suffix=SUFFIX add suffix to file basename
|
-s, --suffix=SUFFIX add suffix to file basename
|
||||||
-c, --cover extract cover
|
-c, --cover extract cover
|
||||||
-t, --thumbnail extract cover thumbnail (freedesktop spec.)
|
-t, --thumbnail extract cover thumbnail (freedesktop spec.)
|
||||||
-o, --outdir="." output directory
|
-o, --outdir="." output directory
|
||||||
-m, --size=0 process only files larger then size (in MB)
|
-m, --size=0 process only files larger then size (in MB)
|
||||||
-r, --recursive process subdirectories recursively
|
-R, --recursive process subdirectories recursively
|
||||||
-Q, --quiet hide console output
|
-Q, --quiet hide console output
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -66,11 +66,11 @@ Convert all images in archive to 4bit BMP image and save result in ~/comics dire
|
|||||||
|
|
||||||
cbconvert --bmp --outdir ~/comics /media/comics/Garfield/Garfield_01.cbz
|
cbconvert --bmp --outdir ~/comics /media/comics/Garfield/Garfield_01.cbz
|
||||||
|
|
||||||
[BMP](http://en.wikipedia.org/wiki/BMP_file_format) format is uncompressed, for black&white pages very good choice. Archive size can be smaller 2-3x and 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 in ~/.thumbnails/normal directory, Lanczos3 algorithm is used for resizing:
|
Generate thumbnails by freedesktop specification in ~/.thumbnails/normal directory, Lanczos3 algorithm is used for resizing:
|
||||||
|
|
||||||
cbconvert --interpolation=5 --outdir ~/.thumbnails/normal --thumbnail /media/comics/GrooTheWanderer/
|
cbconvert --resize=5 --outdir ~/.thumbnails/normal --thumbnail /media/comics/GrooTheWanderer/
|
||||||
|
|
||||||
Compile
|
Compile
|
||||||
-------
|
-------
|
||||||
|
16
cbconvert.go
16
cbconvert.go
@@ -68,7 +68,7 @@ type options struct {
|
|||||||
NoRGB bool // do not convert images with RGB colorspace
|
NoRGB bool // do not convert images with RGB colorspace
|
||||||
Width uint // image width
|
Width uint // image width
|
||||||
Height uint // image height
|
Height uint // image height
|
||||||
Interpolation int // 0=NearestNeighbor, 1=Bilinear, 2=Bicubic, 3=MitchellNetravali, 4=Lanczos2, 5=Lanczos3
|
Resize int // 0=NearestNeighbor, 1=Bilinear, 2=Bicubic, 3=MitchellNetravali, 4=Lanczos2, 5=Lanczos3
|
||||||
Suffix string // add suffix to file basename
|
Suffix string // add suffix to file basename
|
||||||
Cover bool // extract cover
|
Cover bool // extract cover
|
||||||
Thumbnail bool // extract cover thumbnail (freedesktop spec.)
|
Thumbnail bool // extract cover thumbnail (freedesktop spec.)
|
||||||
@@ -107,7 +107,7 @@ func convertImage(img image.Image, index int, pathName string) {
|
|||||||
var i image.Image
|
var i image.Image
|
||||||
if opts.Width > 0 || opts.Height > 0 {
|
if opts.Width > 0 || opts.Height > 0 {
|
||||||
i = resize.Resize(opts.Width, opts.Height, img,
|
i = resize.Resize(opts.Width, opts.Height, img,
|
||||||
resize.InterpolationFunction(opts.Interpolation))
|
resize.InterpolationFunction(opts.Resize))
|
||||||
} else {
|
} else {
|
||||||
i = img
|
i = img
|
||||||
}
|
}
|
||||||
@@ -705,7 +705,7 @@ func extractCover(file string, info os.FileInfo) {
|
|||||||
|
|
||||||
if opts.Width > 0 || opts.Height > 0 {
|
if opts.Width > 0 || opts.Height > 0 {
|
||||||
cover = resize.Resize(opts.Width, opts.Height, cover,
|
cover = resize.Resize(opts.Width, opts.Height, cover,
|
||||||
resize.InterpolationFunction(opts.Interpolation))
|
resize.InterpolationFunction(opts.Resize))
|
||||||
}
|
}
|
||||||
|
|
||||||
filename := filepath.Join(opts.Outdir, fmt.Sprintf("%s.jpg", getBasename(file)))
|
filename := filepath.Join(opts.Outdir, fmt.Sprintf("%s.jpg", getBasename(file)))
|
||||||
@@ -738,10 +738,10 @@ func extractThumbnail(file string, info os.FileInfo) {
|
|||||||
|
|
||||||
if opts.Width > 0 || opts.Height > 0 {
|
if opts.Width > 0 || opts.Height > 0 {
|
||||||
cover = resize.Resize(opts.Width, opts.Height, cover,
|
cover = resize.Resize(opts.Width, opts.Height, cover,
|
||||||
resize.InterpolationFunction(opts.Interpolation))
|
resize.InterpolationFunction(opts.Resize))
|
||||||
} else {
|
} else {
|
||||||
cover = resize.Resize(256, 0, cover,
|
cover = resize.Resize(256, 0, cover,
|
||||||
resize.InterpolationFunction(opts.Interpolation))
|
resize.InterpolationFunction(opts.Resize))
|
||||||
}
|
}
|
||||||
|
|
||||||
imagick.Initialize()
|
imagick.Initialize()
|
||||||
@@ -797,14 +797,14 @@ func parseFlags() {
|
|||||||
kingpin.Flag("height", "image height").Default(strconv.Itoa(0)).Short('h').UintVar(&opts.Height)
|
kingpin.Flag("height", "image height").Default(strconv.Itoa(0)).Short('h').UintVar(&opts.Height)
|
||||||
kingpin.Flag("quality", "JPEG image quality").Short('q').Default(strconv.Itoa(jpeg.DefaultQuality)).IntVar(&opts.Quality)
|
kingpin.Flag("quality", "JPEG image quality").Short('q').Default(strconv.Itoa(jpeg.DefaultQuality)).IntVar(&opts.Quality)
|
||||||
kingpin.Flag("norgb", "do not convert images with RGB colorspace").Short('n').BoolVar(&opts.NoRGB)
|
kingpin.Flag("norgb", "do not convert images with RGB colorspace").Short('n').BoolVar(&opts.NoRGB)
|
||||||
kingpin.Flag("interpolation", "0=NearestNeighbor, 1=Bilinear, 2=Bicubic, 3=MitchellNetravali, 4=Lanczos2, 5=Lanczos3").Short('i').
|
kingpin.Flag("resize", "0=NearestNeighbor, 1=Bilinear, 2=Bicubic, 3=MitchellNetravali, 4=Lanczos2, 5=Lanczos3").Short('r').
|
||||||
Default(strconv.Itoa(int(resize.Bilinear))).IntVar(&opts.Interpolation)
|
Default(strconv.Itoa(int(resize.Bilinear))).IntVar(&opts.Resize)
|
||||||
kingpin.Flag("suffix", "add suffix to file basename").Short('s').StringVar(&opts.Suffix)
|
kingpin.Flag("suffix", "add suffix to file basename").Short('s').StringVar(&opts.Suffix)
|
||||||
kingpin.Flag("cover", "extract cover").Short('c').BoolVar(&opts.Cover)
|
kingpin.Flag("cover", "extract cover").Short('c').BoolVar(&opts.Cover)
|
||||||
kingpin.Flag("thumbnail", "extract cover thumbnail (freedesktop spec.)").Short('t').BoolVar(&opts.Thumbnail)
|
kingpin.Flag("thumbnail", "extract cover thumbnail (freedesktop spec.)").Short('t').BoolVar(&opts.Thumbnail)
|
||||||
kingpin.Flag("outdir", "output directory").Default(".").Short('o').StringVar(&opts.Outdir)
|
kingpin.Flag("outdir", "output directory").Default(".").Short('o').StringVar(&opts.Outdir)
|
||||||
kingpin.Flag("size", "process only files larger then size (in MB)").Short('m').Default(strconv.Itoa(0)).Int64Var(&opts.Size)
|
kingpin.Flag("size", "process only files larger then size (in MB)").Short('m').Default(strconv.Itoa(0)).Int64Var(&opts.Size)
|
||||||
kingpin.Flag("recursive", "process subdirectories recursively").Short('r').BoolVar(&opts.Recursive)
|
kingpin.Flag("recursive", "process subdirectories recursively").Short('R').BoolVar(&opts.Recursive)
|
||||||
kingpin.Flag("quiet", "hide console output").Short('Q').BoolVar(&opts.Quiet)
|
kingpin.Flag("quiet", "hide console output").Short('Q').BoolVar(&opts.Quiet)
|
||||||
kingpin.Arg("args", "filename or directory").Required().ExistingFilesOrDirsVar(&arguments)
|
kingpin.Arg("args", "filename or directory").Required().ExistingFilesOrDirsVar(&arguments)
|
||||||
kingpin.Parse()
|
kingpin.Parse()
|
||||||
|
Reference in New Issue
Block a user