Skip to content

Commit

Permalink
feat: switch scripts program over to timber from lumber
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Gleich <git@mattglei.ch>
  • Loading branch information
gleich committed Jan 15, 2025
1 parent fea6c5e commit 446b2df
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
8 changes: 4 additions & 4 deletions scripts/photos/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ go 1.23

require (
github.com/buckket/go-blurhash v1.1.0
github.com/gleich/lumber/v3 v3.0.1
pkg.mattglei.ch/timber v1.0.0
)

require (
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/lipgloss v0.13.0 // indirect
github.com/charmbracelet/x/ansi v0.2.2 // indirect
github.com/charmbracelet/lipgloss v1.0.0 // indirect
github.com/charmbracelet/x/ansi v0.7.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/sys v0.29.0 // indirect
)
16 changes: 8 additions & 8 deletions scripts/photos/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiE
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/buckket/go-blurhash v1.1.0 h1:X5M6r0LIvwdvKiUtiNcRL2YlmOfMzYobI3VCKCZc9Do=
github.com/buckket/go-blurhash v1.1.0/go.mod h1:aT2iqo5W9vu9GpyoLErKfTHwgODsZp3bQfXjXJUxNb8=
github.com/charmbracelet/lipgloss v0.13.0 h1:4X3PPeoWEDCMvzDvGmTajSyYPcZM4+y8sCA/SsA3cjw=
github.com/charmbracelet/lipgloss v0.13.0/go.mod h1:nw4zy0SBX/F/eAO1cWdcvy6qnkDUxr8Lw7dvFrAIbbY=
github.com/charmbracelet/x/ansi v0.2.2 h1:BC7xzaVpfWIYZRNE8NhO9zo8KA4eGUL6L/JWXDh3GF0=
github.com/charmbracelet/x/ansi v0.2.2/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw=
github.com/gleich/lumber/v3 v3.0.1 h1:swVH/yAlEkcE5faJnXQJVbGs/R2YcJpXI47dyUtR++Q=
github.com/gleich/lumber/v3 v3.0.1/go.mod h1:VWZc7cGxgHGdEDh9tyGusYexsl88DunuBlG2WvWVW+0=
github.com/charmbracelet/lipgloss v1.0.0 h1:O7VkGDvqEdGi93X+DeqsQ7PKHDgtQfF8j8/O2qFMQNg=
github.com/charmbracelet/lipgloss v1.0.0/go.mod h1:U5fy9Z+C38obMs+T+tJqst9VGzlOYGj4ri9reL3qUlo=
github.com/charmbracelet/x/ansi v0.7.0 h1:/QfFmiXOGGwN6fRbzvQaYp7fu1pkxpZ3qFBZWBsP404=
github.com/charmbracelet/x/ansi v0.7.0/go.mod h1:KBUFw1la39nl0dLl10l5ORDAqGXaeurTQmwyyVKse/Q=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
Expand All @@ -22,5 +20,7 @@ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
pkg.mattglei.ch/timber v1.0.0 h1:OQk7AyFZhfAeADbAj8wXBg/pD1fBngSWYD3EJ/v34HE=
pkg.mattglei.ch/timber v1.0.0/go.mod h1:Go9fz7dL27Oo7t3ksPAthw6JzCJmUMdSiEbqZhKDxLc=
20 changes: 10 additions & 10 deletions scripts/photos/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"strings"

"github.com/buckket/go-blurhash"
"github.com/gleich/lumber/v3"
"pkg.mattglei.ch/timber"
)

const photos_folder = "../../public/photos"
Expand All @@ -26,10 +26,10 @@ type photo struct {
}

func main() {
lumber.Info("BOOTED")
timber.Info("BOOTED")
files, err := os.ReadDir(photos_folder)
if err != nil {
lumber.Fatal(err, "Failed to read photos folder")
timber.Fatal(err, "Failed to read photos folder")
}

photos := []photo{}
Expand All @@ -38,19 +38,19 @@ func main() {
name := file.Name()
reader, err := os.Open(filepath.Join(photos_folder, name))
if err != nil {
lumber.Fatal(err, "Failed to read image:", name)
timber.Fatal(err, "Failed to read image:", name)
}
defer reader.Close()

parsedJPG, err := jpeg.Decode(reader)
if err != nil {
lumber.Fatal(err, "Parsing JPEG failed for", name)
timber.Fatal(err, "Parsing JPEG failed for", name)
}
width := parsedJPG.Bounds().Dx()
height := parsedJPG.Bounds().Dy()
blurData, err := blurhash.Encode(4, 3, parsedJPG)
if err != nil {
lumber.Fatal(err, "Creating blur data for", name, "failed")
timber.Fatal(err, "Creating blur data for", name, "failed")
}

scaleDownFactor := 200
Expand All @@ -61,12 +61,12 @@ func main() {
1,
)
if err != nil {
lumber.Fatal(err, "Encoding blurhash data to img failed for", name)
timber.Fatal(err, "Encoding blurhash data to img failed for", name)
}
blurImageOut := new(bytes.Buffer)
err = png.Encode(blurImageOut, blurImage)
if err != nil {
lumber.Fatal(err, "Writing data to PNG failed", name)
timber.Fatal(err, "Writing data to PNG failed", name)
}
base64BlurData := base64.StdEncoding.EncodeToString(blurImageOut.Bytes())

Expand All @@ -83,12 +83,12 @@ func main() {
BlurDataURL: base64BlurData,
},
)
lumber.Done("Processed", name)
timber.Done("Processed", name)
}
}

fmt.Println()
lumber.Done("DATA ARRAY:\n")
timber.Done("DATA ARRAY:\n")
fmt.Println("const images: GalleryImage[] = [")
for _, photo := range photos {
fmt.Println("\t{")
Expand Down

0 comments on commit 446b2df

Please sign in to comment.