mirror of
https://github.com/gen2brain/cbconvert
synced 2025-10-14 02:28:51 +02:00
add option to remove non-image files from archive
This commit is contained in:
@@ -41,8 +41,9 @@ Using
|
||||
-w, --width=0 image width
|
||||
-h, --height=0 image height
|
||||
-q, --quality=75 JPEG image quality
|
||||
-n, --norgb do not convert images with RGB colorspace
|
||||
-f, --filter=0 0=NearestNeighbor, 1=Box, 2=Linear, 3=MitchellNetravali, 4=CatmullRom, 6=Gaussian, 7=Lanczos
|
||||
-f, --filter=2 0=NearestNeighbor, 1=Box, 2=Linear, 3=MitchellNetravali, 4=CatmullRom, 6=Gaussian, 7=Lanczos
|
||||
-N, --no_rgb do not convert images that have RGB colorspace
|
||||
-I, --no_nonimage remove non image files from archive
|
||||
-s, --suffix=SUFFIX add suffix to file basename
|
||||
-c, --cover extract cover
|
||||
-t, --thumbnail extract cover thumbnail (freedesktop spec.)
|
||||
|
10
cbconvert.go
10
cbconvert.go
@@ -87,10 +87,11 @@ type options struct {
|
||||
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 that have RGB colorspace
|
||||
Width int // image width
|
||||
Height int // image height
|
||||
Filter int // 0=NearestNeighbor, 1=Box, 2=Linear, 3=MitchellNetravali, 4=CatmullRom, 6=Gaussian, 7=Lanczos
|
||||
NoRGB bool // do not convert images that have RGB colorspace
|
||||
NoNonImage bool // remove non image files from archive
|
||||
Suffix string // add suffix to file basename
|
||||
Cover bool // extract cover
|
||||
Thumbnail bool // extract cover thumbnail (freedesktop spec.)
|
||||
@@ -326,9 +327,11 @@ func convertArchive(file string) {
|
||||
go convertImage(img, 0, pathname)
|
||||
}
|
||||
} else {
|
||||
if !opts.NoNonImage {
|
||||
copyFile(bytes.NewReader(buf), filepath.Join(workdir, filepath.Base(pathname)))
|
||||
}
|
||||
}
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
@@ -846,8 +849,9 @@ func parseFlags() {
|
||||
kingpin.Flag("height", "image height").Default(strconv.Itoa(0)).Short('h').IntVar(&opts.Height)
|
||||
kingpin.Flag("quality", "JPEG image quality").Short('q').Default(strconv.Itoa(jpeg.DefaultQuality)).IntVar(&opts.Quality)
|
||||
kingpin.Flag("filter", "0=NearestNeighbor, 1=Box, 2=Linear, 3=MitchellNetravali, 4=CatmullRom, 6=Gaussian, 7=Lanczos").Short('f').
|
||||
Default(strconv.Itoa(NearestNeighbor)).IntVar(&opts.Filter)
|
||||
kingpin.Flag("norgb", "do not convert images that have RGB colorspace").Short('n').BoolVar(&opts.NoRGB)
|
||||
Default(strconv.Itoa(Linear)).IntVar(&opts.Filter)
|
||||
kingpin.Flag("no_rgb", "do not convert images that have RGB colorspace").Short('N').BoolVar(&opts.NoRGB)
|
||||
kingpin.Flag("no_nonimage", "remove non image files from archive").Short('I').BoolVar(&opts.NoNonImage)
|
||||
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)
|
||||
|
Reference in New Issue
Block a user