Compare commits
2 Commits
1db7b2b4ad
...
efda3b72b8
Author | SHA1 | Date | |
---|---|---|---|
efda3b72b8 | |||
04a5dd62b6 |
@ -10,6 +10,7 @@ import (
|
||||
"io"
|
||||
"io/fs"
|
||||
|
||||
"github.com/disintegration/imaging"
|
||||
"go.oneofone.dev/resize"
|
||||
)
|
||||
|
||||
@ -102,6 +103,6 @@ func GetImage(source fs.FS, imageName string) (image.Image, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
img, _, err := image.Decode(imgF)
|
||||
img, err := imaging.Decode(imgF, imaging.AutoOrientation(true))
|
||||
return img, err
|
||||
}
|
||||
|
1
go.mod
1
go.mod
@ -3,6 +3,7 @@ module go.balki.me/collage-maker
|
||||
go 1.22
|
||||
|
||||
require (
|
||||
github.com/disintegration/imaging v1.6.2
|
||||
go.balki.me/anyhttp v0.3.0
|
||||
go.oneofone.dev/resize v1.0.1
|
||||
)
|
||||
|
3
go.sum
3
go.sum
@ -1,3 +1,5 @@
|
||||
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=
|
||||
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
go.balki.me/anyhttp v0.3.0 h1:WtBQ0rnkg567sX/O4ij/+qBbdCIUt5VURSe718sITBY=
|
||||
go.balki.me/anyhttp v0.3.0/go.mod h1:JhfekOIjgVODoVqUCficjpIgmB3wwlB7jhN0eN2EZ/s=
|
||||
@ -5,6 +7,7 @@ go.oneofone.dev/resize v1.0.1 h1:HjpVar/4pxMGrjO44ThaMX1Q5UOBw0KxzbxxRDZPQuA=
|
||||
go.oneofone.dev/resize v1.0.1/go.mod h1:zGFmn7q4EUZVlnDmxqf+b0mWpxsTt0MH2yx6ng8tpq0=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.1.0 h1:r8Oj8ZA2Xy12/b5KZYj3tuv7NG/fBz3TwQVvpJ9l8Rk=
|
||||
golang.org/x/image v0.1.0/go.mod h1:iyPr49SD/G/TBxYVB/9RRtGUT5eNbo2u4NamWeQcD5c=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
|
6
main.go
6
main.go
@ -24,7 +24,6 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
imagesDir string
|
||||
collageDir string
|
||||
photosDir string
|
||||
devMode bool
|
||||
@ -41,7 +40,6 @@ var (
|
||||
func main() {
|
||||
var ppURL string
|
||||
|
||||
flag.StringVar(&imagesDir, "images-dir", "images", "Sets the images dir")
|
||||
flag.StringVar(&collageDir, "collages-dir", "collages", "Sets the collages dir")
|
||||
flag.StringVar(&photosDir, "photos-dir", "photos", "Cache directory for downloaded photos")
|
||||
flag.BoolVar(&devMode, "dev", false, "Serve local assets during development")
|
||||
@ -59,8 +57,7 @@ func main() {
|
||||
return photoPrismURL
|
||||
}()
|
||||
collageNameGen = NewNameGen()
|
||||
imagesDirFs = os.DirFS(imagesDir)
|
||||
imagesURLPath := "images"
|
||||
imagesDirFs = os.DirFS(photosDir)
|
||||
collagesPath := "collages"
|
||||
photosPath := "photos"
|
||||
|
||||
@ -69,7 +66,6 @@ func main() {
|
||||
http.Handle("/"+path+"/", http.StripPrefix("/"+path, httpFileServer))
|
||||
}
|
||||
|
||||
addFileServer(imagesURLPath, imagesDir)
|
||||
addFileServer(collagesPath, collageDir)
|
||||
addFileServer(photosPath, photosDir)
|
||||
|
||||
|
@ -148,8 +148,12 @@ function snap() {
|
||||
const fsx = elem.offsetLeft - col
|
||||
const fsy = elem.offsetTop - cot
|
||||
const [sx, sy, ex, ey] = cpie.get().points;
|
||||
const imageFile = (() => {
|
||||
const u = new URL(elem.dataset.collageImageUrl)
|
||||
return u.pathname.slice("/photos/".length)
|
||||
})();
|
||||
const photo = {
|
||||
image: elem.dataset.collageImageUrl.slice("images/".length),
|
||||
image: imageFile,
|
||||
crop: {
|
||||
start: {
|
||||
x: parseInt(sx),
|
||||
|
Loading…
Reference in New Issue
Block a user