Skip to content

Commit

Permalink
feat: support tiff images
Browse files Browse the repository at this point in the history
closes #126
  • Loading branch information
sentriz committed Nov 20, 2024
1 parent 8c48df7 commit 1350191
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions cliphist.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"go.senan.xyz/flagconf"
_ "golang.org/x/image/bmp"
_ "golang.org/x/image/tiff"

bolt "go.etcd.io/bbolt"
)
Expand Down
10 changes: 6 additions & 4 deletions cliphist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"github.com/rogpeppe/go-internal/testscript"
"golang.org/x/image/bmp"
"golang.org/x/image/tiff"
)

func TestMain(m *testing.M) {
Expand All @@ -39,10 +40,11 @@ func TestMain(m *testing.M) {
return 0
},

"gif": func() int { _ = gif.Encode(os.Stdout, testImage, nil); return 0 },
"jpg": func() int { _ = jpeg.Encode(os.Stdout, testImage, nil); return 0 },
"png": func() int { _ = png.Encode(os.Stdout, testImage); return 0 },
"bmp": func() int { _ = bmp.Encode(os.Stdout, testImage); return 0 },
"gif": func() int { _ = gif.Encode(os.Stdout, testImage, nil); return 0 },
"jpg": func() int { _ = jpeg.Encode(os.Stdout, testImage, nil); return 0 },
"png": func() int { _ = png.Encode(os.Stdout, testImage); return 0 },
"bmp": func() int { _ = bmp.Encode(os.Stdout, testImage); return 0 },
"tiff": func() int { _ = tiff.Encode(os.Stdout, testImage, nil); return 0 },
}))
}

Expand Down
19 changes: 19 additions & 0 deletions testdata/test-image-and-preview-tiff.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
exec tiff
cp stdout in.tiff

stdin stdout
exec cliphist store

# check we render preview
exec cliphist list
stdout '\[\[ binary data \d+ KiB tiff 20x20 \]\]'

stdin query
exec cliphist decode
cp stdout out.tiff

# check we didn't lose any bytes
cmp in.tiff out.tiff

-- query --
1

0 comments on commit 1350191

Please sign in to comment.