使用gamma校正提升jpg亮度

This commit is contained in:
nuknal
2024-05-30 11:22:34 +08:00
parent 7d9ec46750
commit 07ee4d88d4
18 changed files with 174 additions and 98 deletions

55
pkg/producer/hdr.go Normal file
View File

@@ -0,0 +1,55 @@
package imageproc
import (
"bytes"
"html"
"os"
"text/template"
)
var HDRTemplate = `ENVI
description = {
File Imported into ENVI.}
samples = {{.Samples}}
lines = {{.Lines}}
bands = {{.Bands}}
header offset = 0
file type = ENVI Standard
data type = 12
interleave = bsq
sensor type = Unknown
byte order = 0
wavelength units = Unknown`
// https://www.nv5geospatialsoftware.com/docs/ENVIHeaderFiles.html
type EnviHdr struct {
Samples int // samples (pixels) each line
Lines int
Bands int
}
func (h *EnviHdr) String() string {
var t *template.Template
t = template.New("template")
t, err := t.Parse(HDRTemplate)
if err != nil {
return ""
}
buf := new(bytes.Buffer)
t.Execute(buf, h)
buf = bytes.NewBufferString(html.UnescapeString(buf.String()))
return buf.String()
}
func (h *EnviHdr) Write(filename string) error {
str := h.String()
f, err := os.Create(filename)
if err != nil {
return err
}
defer f.Close()
_, err = f.WriteString(str)
return err
}