Skip to content

Commit

Permalink
Merge pull request #10 from trashhalo/fix-exif
Browse files Browse the repository at this point in the history
handle exif data so jpgs will be rotated correctly. fixes #8
  • Loading branch information
Stephen Solka authored Oct 27, 2020
2 parents 7536dac + aacee7d commit 0668f55
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ go 1.14

require (
github.com/charmbracelet/bubbletea v0.12.0
github.com/disintegration/imageorient v0.0.0-20180920195336-8147d86e83ec
github.com/lucasb-eyer/go-colorful v1.0.3
github.com/muesli/termenv v0.7.4
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634
)
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ github.com/charmbracelet/bubbletea v0.12.0 h1:/pUHp1GWRDyK1TJAWkXrnRH1u8Xc5076oH
github.com/charmbracelet/bubbletea v0.12.0/go.mod h1:3gZkYELUOiEUOp0bTInkxguucy/xRbGSOcbMs1geLxg=
github.com/containerd/console v1.0.1 h1:u7SFAJyRqWcG6ogaMAx3KjSTy1e3hT9QxqX7Jco7dRc=
github.com/containerd/console v1.0.1/go.mod h1:XUsP6YE/mKtz6bxc+I8UiKKTP04qjQL4qcS3XoQ5xkw=
github.com/disintegration/gift v1.1.2 h1:9ZyHJr+kPamiH10FX3Pynt1AxFUob812bU9Wt4GMzhs=
github.com/disintegration/gift v1.1.2/go.mod h1:Jh2i7f7Q2BM7Ezno3PhfezbR1xpUg9dUg3/RlKGr4HI=
github.com/disintegration/imageorient v0.0.0-20180920195336-8147d86e83ec h1:YrB6aVr9touOt75I9O1SiancmR2GMg45U9UYf0gtgWg=
github.com/disintegration/imageorient v0.0.0-20180920195336-8147d86e83ec/go.mod h1:K0KBFIr1gWu/C1Gp10nFAcAE4hsB7JxE6OgLijrJ8Sk=
github.com/google/goterm v0.0.0-20190703233501-fc88cf888a3f/go.mod h1:nOFQdrUlIlx6M6ODdSpBj1NVA+VgLC6kmw60mkw34H4=
github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
Expand Down
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"time"

tea "github.com/charmbracelet/bubbletea"
"github.com/disintegration/imageorient"
"github.com/lucasb-eyer/go-colorful"
"github.com/muesli/termenv"
"github.com/nfnt/resize"
Expand Down Expand Up @@ -250,7 +251,7 @@ func load(url string) tea.Cmd {
}

func readerToImage(width uint, height uint, url string, r io.Reader) (string, error) {
img, _, err := image.Decode(r)
img, _, err := imageorient.Decode(r)
if err != nil {
return "", err
}
Expand All @@ -259,7 +260,7 @@ func readerToImage(width uint, height uint, url string, r io.Reader) (string, er
}

func imageToString(width, height uint, url string, img image.Image) (string, error) {
img = resize.Thumbnail(width, height*2, img, resize.Lanczos3)
img = resize.Thumbnail(width, height*2-4, img, resize.Lanczos3)
b := img.Bounds()
w := b.Max.X
h := b.Max.Y
Expand Down

0 comments on commit 0668f55

Please sign in to comment.