mirror of
https://github.com/gen2brain/cbconvert
synced 2025-10-14 02:28:51 +02:00
add brightness and contrast options
This commit is contained in:
@@ -66,6 +66,8 @@ Using
|
|||||||
--grayscale Convert images to grayscale (monochromatic)
|
--grayscale Convert images to grayscale (monochromatic)
|
||||||
--rotate=0 Rotate images, valid values are 0, 90, 180, 270
|
--rotate=0 Rotate images, valid values are 0, 90, 180, 270
|
||||||
--flip="none" Flip images, valid values are none, horizontal, vertical
|
--flip="none" Flip images, valid values are none, horizontal, vertical
|
||||||
|
--brightness=0 Changes the brightness of the images, must be in range (-100, 100)
|
||||||
|
--contrast=0 Changes the contrast of the images, must be in range (-100, 100)
|
||||||
--suffix=SUFFIX Add suffix to file basename
|
--suffix=SUFFIX Add suffix to file basename
|
||||||
|
|
||||||
cover [<flags>] <args>...
|
cover [<flags>] <args>...
|
||||||
|
54
cbconvert.go
54
cbconvert.go
@@ -83,27 +83,29 @@ var (
|
|||||||
|
|
||||||
// Command line options
|
// Command line options
|
||||||
type options struct {
|
type options struct {
|
||||||
ToPNG bool // encode images to PNG instead of JPEG
|
ToPNG bool // encode images to PNG instead of JPEG
|
||||||
ToBMP bool // encode images to 4-Bit BMP (16 colors) 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
|
ToGIF bool // encode images to GIF instead of JPEG
|
||||||
ToTIFF bool // encode images to TIFF instead of JPEG
|
ToTIFF bool // encode images to TIFF instead of JPEG
|
||||||
Quality int // JPEG image quality
|
Quality int // JPEG image quality
|
||||||
Width int // image width
|
Width int // image width
|
||||||
Height int // image height
|
Height int // image height
|
||||||
Fit bool // Best fit for required width and height
|
Fit bool // Best fit for required width and height
|
||||||
Filter int // 0=NearestNeighbor, 1=Box, 2=Linear, 3=MitchellNetravali, 4=CatmullRom, 6=Gaussian, 7=Lanczos
|
Filter int // 0=NearestNeighbor, 1=Box, 2=Linear, 3=MitchellNetravali, 4=CatmullRom, 6=Gaussian, 7=Lanczos
|
||||||
RGB bool // convert images that have RGB colorspace
|
RGB bool // convert images that have RGB colorspace
|
||||||
NonImage bool // Leave non image files in archive
|
NonImage bool // Leave non image files in archive
|
||||||
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.)
|
||||||
Outdir string // output directory
|
Outdir string // output directory
|
||||||
Grayscale bool // convert images to grayscale (monochromatic)
|
Grayscale bool // convert images to grayscale (monochromatic)
|
||||||
Rotate int // Rotate images, valid values are 0, 90, 180, 270
|
Rotate int // Rotate images, valid values are 0, 90, 180, 270
|
||||||
Flip string // Flip images, valid values are none, horizontal, vertical
|
Flip string // Flip images, valid values are none, horizontal, vertical
|
||||||
Recursive bool // process subdirectories recursively
|
Brightness float64 // Changes the brightness of the images, must be in range (-100, 100)
|
||||||
Size int64 // process only files larger then size (in MB)
|
Contrast float64 // Changes the contrast of the images, must be in range (-100, 100)
|
||||||
Quiet bool // hide console output
|
Recursive bool // process subdirectories recursively
|
||||||
|
Size int64 // process only files larger then size (in MB)
|
||||||
|
Quiet bool // hide console output
|
||||||
}
|
}
|
||||||
|
|
||||||
// Command line arguments
|
// Command line arguments
|
||||||
@@ -194,6 +196,14 @@ func transformImage(img image.Image) image.Image {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if opts.Brightness != 0 {
|
||||||
|
i = imaging.AdjustBrightness(i, opts.Brightness)
|
||||||
|
}
|
||||||
|
|
||||||
|
if opts.Contrast != 0 {
|
||||||
|
i = imaging.AdjustContrast(i, opts.Contrast)
|
||||||
|
}
|
||||||
|
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -919,6 +929,8 @@ func parseFlags() {
|
|||||||
convert.Flag("grayscale", "Convert images to grayscale (monochromatic)").BoolVar(&opts.Grayscale)
|
convert.Flag("grayscale", "Convert images to grayscale (monochromatic)").BoolVar(&opts.Grayscale)
|
||||||
convert.Flag("rotate", "Rotate images, valid values are 0, 90, 180, 270").Default(strconv.Itoa(0)).IntVar(&opts.Rotate)
|
convert.Flag("rotate", "Rotate images, valid values are 0, 90, 180, 270").Default(strconv.Itoa(0)).IntVar(&opts.Rotate)
|
||||||
convert.Flag("flip", "Flip images, valid values are none, horizontal, vertical").Default("none").StringVar(&opts.Flip)
|
convert.Flag("flip", "Flip images, valid values are none, horizontal, vertical").Default("none").StringVar(&opts.Flip)
|
||||||
|
convert.Flag("brightness", "Changes the brightness of the images, must be in range (-100, 100)").Default(strconv.Itoa(0)).Float64Var(&opts.Brightness)
|
||||||
|
convert.Flag("contrast", "Changes the contrast of the images, must be in range (-100, 100)").Default(strconv.Itoa(0)).Float64Var(&opts.Contrast)
|
||||||
convert.Flag("suffix", "Add suffix to file basename").StringVar(&opts.Suffix)
|
convert.Flag("suffix", "Add suffix to file basename").StringVar(&opts.Suffix)
|
||||||
|
|
||||||
cover := kingpin.Command("cover", "Extract cover")
|
cover := kingpin.Command("cover", "Extract cover")
|
||||||
|
Reference in New Issue
Block a user