From 55b53efcca0d1cfea990ac2e70442fe39d765d36 Mon Sep 17 00:00:00 2001 From: Milan Nikolic Date: Tue, 3 Nov 2015 20:13:25 +0100 Subject: [PATCH] rename interp. to resize --- README.md | 8 ++++---- cbconvert.go | 44 ++++++++++++++++++++++---------------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 78e4f33..1f9bb51 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ Using -h, --height=0 image height -q, --quality=75 JPEG image quality -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 -c, --cover extract cover -t, --thumbnail extract cover thumbnail (freedesktop spec.) -o, --outdir="." output directory -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 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 -[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: - cbconvert --interpolation=5 --outdir ~/.thumbnails/normal --thumbnail /media/comics/GrooTheWanderer/ + cbconvert --resize=5 --outdir ~/.thumbnails/normal --thumbnail /media/comics/GrooTheWanderer/ Compile ------- diff --git a/cbconvert.go b/cbconvert.go index c53d959..5bd5ebe 100644 --- a/cbconvert.go +++ b/cbconvert.go @@ -61,21 +61,21 @@ var ( // Command line options type options struct { - ToPNG bool // encode images to PNG instead of JPEG - ToBMP bool // encode images to 4-Bit BMP (16 colors) instead of JPEG - ToGIF bool // encode images to GIF instead of JPEG - Quality int // JPEG image quality - NoRGB bool // do not convert images with RGB colorspace - Width uint // image width - Height uint // image height - Interpolation int // 0=NearestNeighbor, 1=Bilinear, 2=Bicubic, 3=MitchellNetravali, 4=Lanczos2, 5=Lanczos3 - Suffix string // add suffix to file basename - Cover bool // extract cover - Thumbnail bool // extract cover thumbnail (freedesktop spec.) - Outdir string // output directory - Recursive bool // process subdirectories recursively - Size int64 // process only files larger then size (in MB) - Quiet bool // hide console output + ToPNG bool // encode images to PNG instead of JPEG + ToBMP bool // encode images to 4-Bit BMP (16 colors) instead of JPEG + ToGIF bool // encode images to GIF instead of JPEG + Quality int // JPEG image quality + NoRGB bool // do not convert images with RGB colorspace + Width uint // image width + Height uint // image height + Resize int // 0=NearestNeighbor, 1=Bilinear, 2=Bicubic, 3=MitchellNetravali, 4=Lanczos2, 5=Lanczos3 + Suffix string // add suffix to file basename + Cover bool // extract cover + Thumbnail bool // extract cover thumbnail (freedesktop spec.) + Outdir string // output directory + Recursive bool // process subdirectories recursively + Size int64 // process only files larger then size (in MB) + Quiet bool // hide console output } // Command line arguments @@ -107,7 +107,7 @@ func convertImage(img image.Image, index int, pathName string) { var i image.Image if opts.Width > 0 || opts.Height > 0 { i = resize.Resize(opts.Width, opts.Height, img, - resize.InterpolationFunction(opts.Interpolation)) + resize.InterpolationFunction(opts.Resize)) } else { i = img } @@ -705,7 +705,7 @@ func extractCover(file string, info os.FileInfo) { if opts.Width > 0 || opts.Height > 0 { 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))) @@ -738,10 +738,10 @@ func extractThumbnail(file string, info os.FileInfo) { if opts.Width > 0 || opts.Height > 0 { cover = resize.Resize(opts.Width, opts.Height, cover, - resize.InterpolationFunction(opts.Interpolation)) + resize.InterpolationFunction(opts.Resize)) } else { cover = resize.Resize(256, 0, cover, - resize.InterpolationFunction(opts.Interpolation)) + resize.InterpolationFunction(opts.Resize)) } imagick.Initialize() @@ -797,14 +797,14 @@ func parseFlags() { 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("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'). - Default(strconv.Itoa(int(resize.Bilinear))).IntVar(&opts.Interpolation) + 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.Resize) 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("thumbnail", "extract cover thumbnail (freedesktop spec.)").Short('t').BoolVar(&opts.Thumbnail) 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("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.Arg("args", "filename or directory").Required().ExistingFilesOrDirsVar(&arguments) kingpin.Parse()