From c2311ce87dd2c681406728f885d2228dbefd7a21 Mon Sep 17 00:00:00 2001 From: xuri Date: Sat, 14 May 2022 00:54:36 +0800 Subject: [PATCH] This made library allowing insert WMF format image --- picture.go | 2 +- picture_test.go | 2 ++ test/images/excel.wmf | Bin 0 -> 11208 bytes xmlDrawing.go | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 test/images/excel.wmf diff --git a/picture.go b/picture.go index f8133ca..8e2fa12 100644 --- a/picture.go +++ b/picture.go @@ -366,7 +366,7 @@ func (f *File) addMedia(file []byte, ext string) string { // setContentTypePartImageExtensions provides a function to set the content // type for relationship parts and the Main Document part. func (f *File) setContentTypePartImageExtensions() { - imageTypes := map[string]string{"jpeg": "image/", "png": "image/", "gif": "image/", "tiff": "image/", "emf": "image/x-"} + imageTypes := map[string]string{"jpeg": "image/", "png": "image/", "gif": "image/", "tiff": "image/", "emf": "image/x-", "wmf": "image/x-"} content := f.contentTypesReader() content.Lock() defer content.Unlock() diff --git a/picture_test.go b/picture_test.go index c548035..60c6ac1 100644 --- a/picture_test.go +++ b/picture_test.go @@ -97,7 +97,9 @@ func TestAddPictureErrors(t *testing.T) { decode := func(r io.Reader) (image.Image, error) { return nil, nil } decodeConfig := func(r io.Reader) (image.Config, error) { return image.Config{Height: 100, Width: 90}, nil } image.RegisterFormat("emf", "", decode, decodeConfig) + image.RegisterFormat("wmf", "", decode, decodeConfig) assert.NoError(t, f.AddPicture("Sheet1", "Q1", filepath.Join("test", "images", "excel.emf"), "")) + assert.NoError(t, f.AddPicture("Sheet1", "Q7", filepath.Join("test", "images", "excel.wmf"), "")) assert.NoError(t, f.SaveAs(filepath.Join("test", "TestAddPicture2.xlsx"))) assert.NoError(t, f.Close()) } diff --git a/test/images/excel.wmf b/test/images/excel.wmf new file mode 100644 index 0000000000000000000000000000000000000000..fd588c66f9e2fc1b62ffa766c15c2cf64c584f49 GIT binary patch literal 11208 zcmchdTWl0n7{|}-0;O(y&X!)dX{AbqAeRDiD}r1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