This commit is contained in:
2026-03-29 17:03:48 +03:00
parent 7143e96ef3
commit 3880b353c1
20 changed files with 491 additions and 23 deletions

22
cmd/dither/main.go Normal file
View File

@@ -0,0 +1,22 @@
package main
import (
"flag"
"image"
"git.nkpl.cc/twocookedfaggots/imageutils/pkg/dithering"
"git.nkpl.cc/twocookedfaggots/imageutils/util"
)
var factor = flag.Float64("n", 0.75, "dithering effect 'magic' number")
func main() {
flag.Parse()
println(*factor)
if err := util.ProcessStdio(func(img image.Image) image.Image {
return dithering.Dithering{img, *factor}
}); err != nil {
panic(err)
}
}

39
cmd/negate/negate.go Normal file
View File

@@ -0,0 +1,39 @@
package main
import (
"image"
"image/color"
"git.nkpl.cc/twocookedfaggots/imageutils/util"
)
func NegateRGBA(c color.RGBA) color.RGBA {
c.R = 255 - c.R
c.G = 255 - c.G
c.B = 255 - c.B
return c
}
type Negate struct{ image.Image }
func (n Negate) ColorModel() color.Model { return n.Image.ColorModel() }
func (n Negate) Bounds() image.Rectangle { return n.Image.Bounds() }
func (n Negate) At(x, y int) color.Color {
c := n.Image.At(x, y)
r, g, b, a := c.RGBA()
RGBAColor := color.RGBA{
R: uint8(r >> 8),
G: uint8(g >> 8),
B: uint8(b >> 8),
A: uint8(a >> 8),
}
return NegateRGBA(RGBAColor)
}
func main() {
if err := util.ProcessStdio(func(img image.Image) image.Image {
return Negate{img}
}); err != nil {
panic(err)
}
}

20
cmd/scale/main.go Normal file
View File

@@ -0,0 +1,20 @@
package main
import (
"flag"
"image"
"git.nkpl.cc/twocookedfaggots/imageutils"
"git.nkpl.cc/twocookedfaggots/imageutils/util"
)
var scale = flag.Int("n", 2, "rescale by factor")
func main() {
flag.Parse()
if err := util.ProcessStdio(func(img image.Image) image.Image {
return imageutils.Scale(img, *scale)
}); err != nil {
panic(err)
}
}