|
@@ -62,6 +62,10 @@ func Invert(img image.Image) *image.NRGBA {
|
|
|
// dstImage = imaging.AdjustSaturation(srcImage, -10) // Decrease image saturation by 10%.
|
|
|
//
|
|
|
func AdjustSaturation(img image.Image, percentage float64) *image.NRGBA {
|
|
|
+ if percentage == 0 {
|
|
|
+ return Clone(img)
|
|
|
+ }
|
|
|
+
|
|
|
percentage = math.Min(math.Max(percentage, -100), 100)
|
|
|
multiplier := 1 + percentage/100
|
|
|
|
|
@@ -86,6 +90,10 @@ func AdjustSaturation(img image.Image, percentage float64) *image.NRGBA {
|
|
|
// dstImage = imaging.AdjustContrast(srcImage, 20) // Increase image contrast by 20%.
|
|
|
//
|
|
|
func AdjustContrast(img image.Image, percentage float64) *image.NRGBA {
|
|
|
+ if percentage == 0 {
|
|
|
+ return Clone(img)
|
|
|
+ }
|
|
|
+
|
|
|
percentage = math.Min(math.Max(percentage, -100.0), 100.0)
|
|
|
lut := make([]uint8, 256)
|
|
|
|
|
@@ -114,6 +122,10 @@ func AdjustContrast(img image.Image, percentage float64) *image.NRGBA {
|
|
|
// dstImage = imaging.AdjustBrightness(srcImage, 10) // Increase image brightness by 10%.
|
|
|
//
|
|
|
func AdjustBrightness(img image.Image, percentage float64) *image.NRGBA {
|
|
|
+ if percentage == 0 {
|
|
|
+ return Clone(img)
|
|
|
+ }
|
|
|
+
|
|
|
percentage = math.Min(math.Max(percentage, -100.0), 100.0)
|
|
|
lut := make([]uint8, 256)
|
|
|
|
|
@@ -134,6 +146,10 @@ func AdjustBrightness(img image.Image, percentage float64) *image.NRGBA {
|
|
|
// dstImage = imaging.AdjustGamma(srcImage, 0.7)
|
|
|
//
|
|
|
func AdjustGamma(img image.Image, gamma float64) *image.NRGBA {
|
|
|
+ if gamma == 1 {
|
|
|
+ return Clone(img)
|
|
|
+ }
|
|
|
+
|
|
|
e := 1.0 / math.Max(gamma, 0.0001)
|
|
|
lut := make([]uint8, 256)
|
|
|
|