diff options
author | xuri <xuri.me@gmail.com> | 2022-05-14 00:54:36 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2022-05-14 00:54:36 +0800 |
commit | c2311ce87dd2c681406728f885d2228dbefd7a21 (patch) | |
tree | 6f99cf415fa045d761b18772dd2be59ff7b92887 | |
parent | 0c3fd0223c784ddcc7d2442105b920587b970727 (diff) |
This made library allowing insert WMF format image
-rw-r--r-- | picture.go | 2 | ||||
-rw-r--r-- | picture_test.go | 2 | ||||
-rw-r--r-- | test/images/excel.wmf | bin | 0 -> 11208 bytes | |||
-rw-r--r-- | xmlDrawing.go | 2 |
4 files changed, 4 insertions, 2 deletions
@@ -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 Binary files differnew file mode 100644 index 0000000..fd588c6 --- /dev/null +++ b/test/images/excel.wmf diff --git a/xmlDrawing.go b/xmlDrawing.go index 7d0b2df..0b6df05 100644 --- a/xmlDrawing.go +++ b/xmlDrawing.go @@ -119,7 +119,7 @@ const ( ) // supportedImageTypes defined supported image types. -var supportedImageTypes = map[string]string{".gif": ".gif", ".jpg": ".jpeg", ".jpeg": ".jpeg", ".png": ".png", ".tif": ".tiff", ".tiff": ".tiff", ".emf": ".emf"} +var supportedImageTypes = map[string]string{".gif": ".gif", ".jpg": ".jpeg", ".jpeg": ".jpeg", ".png": ".png", ".tif": ".tiff", ".tiff": ".tiff", ".emf": ".emf", ".wmf": ".wmf"} // xlsxCNvPr directly maps the cNvPr (Non-Visual Drawing Properties). This // element specifies non-visual canvas properties. This allows for additional |