Add files via upload
This commit is contained in:
parent
629df61311
commit
07a3e67d66
2 changed files with 107 additions and 0 deletions
36
go.mod
Normal file
36
go.mod
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
module irene
|
||||
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
fyne.io/fyne v1.4.3
|
||||
fyne.io/fyne/v2 v2.4.0 // indirect
|
||||
fyne.io/systray v1.10.1-0.20230722100817-88df1e0ffa9a // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/fredbi/uri v1.0.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
||||
github.com/fyne-io/gl-js v0.0.0-20220119005834-d2da28d9ccfe // indirect
|
||||
github.com/fyne-io/glfw-js v0.0.0-20220120001248-ee7290d23504 // indirect
|
||||
github.com/fyne-io/image v0.0.0-20220602074514-4956b0afb3d2 // indirect
|
||||
github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20221017161538-93cebf72946b // indirect
|
||||
github.com/go-text/render v0.0.0-20230619120952-35bccb6164b8 // indirect
|
||||
github.com/go-text/typesetting v0.0.0-20230616162802-9c17dd34aa4a // indirect
|
||||
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
||||
github.com/gopherjs/gopherjs v1.17.2 // indirect
|
||||
github.com/h2non/bimg v1.1.9
|
||||
github.com/jsummers/gobmp v0.0.0-20151104160322-e2ba15ffa76e // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c // indirect
|
||||
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef // indirect
|
||||
github.com/stretchr/testify v1.8.4 // indirect
|
||||
github.com/tevino/abool v1.2.0 // indirect
|
||||
github.com/yuin/goldmark v1.5.5 // indirect
|
||||
golang.org/x/image v0.11.0 // indirect
|
||||
golang.org/x/mobile v0.0.0-20230531173138-3c911d8e3eda // indirect
|
||||
golang.org/x/net v0.14.0 // indirect
|
||||
golang.org/x/sys v0.11.0 // indirect
|
||||
golang.org/x/text v0.12.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
honnef.co/go/js/dom v0.0.0-20210725211120-f030747120f2 // indirect
|
||||
)
|
||||
71
main.go
Normal file
71
main.go
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/app"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/layout"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"github.com/h2non/bimg"
|
||||
)
|
||||
|
||||
func main() {
|
||||
a := app.New()
|
||||
w := a.NewWindow("Irene")
|
||||
|
||||
w.Resize(fyne.NewSize(1920/2, 1080/2))
|
||||
|
||||
ScaleText := widget.NewEntry()
|
||||
ScaleText.PlaceHolder = "Scale eg. (2 for Double the size)"
|
||||
ScaleText.TextStyle.Bold = true
|
||||
page_1 := container.New(
|
||||
layout.NewVBoxLayout(),
|
||||
layout.NewSpacer(),
|
||||
widget.NewLabel("Drag Files into window to process"),
|
||||
ScaleText,
|
||||
layout.NewSpacer(),
|
||||
)
|
||||
|
||||
w.SetContent(page_1)
|
||||
w.SetOnDropped(func(p fyne.Position, u []fyne.URI) {
|
||||
for _, uri := range u {
|
||||
|
||||
scale, err := strconv.ParseFloat(ScaleText.Text, 64)
|
||||
if err != nil {
|
||||
fmt.Println("Error:", err)
|
||||
return
|
||||
}
|
||||
|
||||
buffer, err := bimg.Read(uri.Path())
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
}
|
||||
|
||||
image, err := bimg.NewImage(buffer).Size()
|
||||
if err != nil {
|
||||
fmt.Println("Error:", err)
|
||||
return
|
||||
}
|
||||
|
||||
if scale <= 1 {
|
||||
NewWidth, NewHeight := int(float64(image.Width)*scale), int(float64(image.Height)*scale)
|
||||
newImage, _ := bimg.NewImage(buffer).Resize(NewWidth, NewHeight)
|
||||
bimg.Write(uri.Path()+ScaleText.Text+".png", newImage)
|
||||
}
|
||||
|
||||
if scale >= 1 {
|
||||
newImage, _ := bimg.NewImage(buffer).Enlarge(image.Width*int(scale), image.Height*int(scale))
|
||||
bimg.Write(uri.Path()+ScaleText.Text+".png", newImage)
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
w.SetOnClosed(a.Quit)
|
||||
|
||||
w.ShowAndRun()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue