//go:build ignore

// works as i wanted

package main

import (
	"git.nkpl.cc/twocookedfaggots/imageutils"
	"git.nkpl.cc/twocookedfaggots/imageutils/http/blank"
	"image"
	"image/color"
	"image/jpeg"
	"image/png"
	"os"
)

func BlankFillWhite(img image.Image) image.Image {
	dy := img.Bounds().Dy()
	up, down := dy*2/3, dy*1/3
	for i := 0; i < up; i++ {
		img = blank.Blank(img, color.White, imageutils.Up)
	}
	for i := 0; i < down; i++ {
		img = blank.Blank(img, color.White, imageutils.Down)
	}
	return img
}

func ProcessImageStdio(f func(image.Image) image.Image) error {
	img, err := jpeg.Decode(os.Stdin)
	if err != nil {
		return err
	}
	img = f(img)
	err = png.Encode(os.Stdout, img)
	if err != nil {
		return err
	}
	return nil
}

func main() {
	err := ProcessImageStdio(
		BlankFillWhite,
	)
	if err != nil {
		panic(err)
	}
}
