From 1350191061a7df1f70cd6e652eb0517d3a9a590f Mon Sep 17 00:00:00 2001 From: sentriz Date: Wed, 20 Nov 2024 15:21:58 +0000 Subject: [PATCH] feat: support tiff images closes #126 --- cliphist.go | 1 + cliphist_test.go | 10 ++++++---- testdata/test-image-and-preview-tiff.txtar | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 testdata/test-image-and-preview-tiff.txtar diff --git a/cliphist.go b/cliphist.go index 8d4d6c0..bef3dfa 100644 --- a/cliphist.go +++ b/cliphist.go @@ -22,6 +22,7 @@ import ( "go.senan.xyz/flagconf" _ "golang.org/x/image/bmp" + _ "golang.org/x/image/tiff" bolt "go.etcd.io/bbolt" ) diff --git a/cliphist_test.go b/cliphist_test.go index 5ffb9d0..d61d9f8 100644 --- a/cliphist_test.go +++ b/cliphist_test.go @@ -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) { @@ -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 }, })) } diff --git a/testdata/test-image-and-preview-tiff.txtar b/testdata/test-image-and-preview-tiff.txtar new file mode 100644 index 0000000..6b51531 --- /dev/null +++ b/testdata/test-image-and-preview-tiff.txtar @@ -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