Skip to content

Commit

Permalink
document: fix non-PNG image support
Browse files Browse the repository at this point in the history
  • Loading branch information
tbaliance committed Jul 8, 2018
1 parent a78d579 commit 7f7bedb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion document/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"io"
"io/ioutil"
"os"
"strings"

"baliance.com/gooxml"
"baliance.com/gooxml/common"
Expand Down Expand Up @@ -233,7 +234,7 @@ func (d *Document) Save(w io.Writer) error {
}

for i, img := range d.Images {
fn := fmt.Sprintf("word/media/image%d.png", i+1)
fn := fmt.Sprintf("word/media/image%d.%s", i+1, strings.ToLower(img.Format()))
if img.Path() != "" {
if err := zippkg.AddFileFromDisk(z, fn, img.Path()); err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions presentation/presentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"log"
"os"
"path"
"strings"

"baliance.com/gooxml"
"baliance.com/gooxml/common"
Expand Down Expand Up @@ -440,6 +441,7 @@ func (p *Presentation) Save(w io.Writer) error {

for i, img := range p.Images {
fn := gooxml.AbsoluteFilename(gooxml.DocTypePresentation, gooxml.ImageType, i+1)
fn = fn[0:len(fn)-3] + strings.ToLower(img.Format())
if img.Path() != "" {
if err := zippkg.AddFileFromDisk(z, fn, img.Path()); err != nil {
return err
Expand Down

0 comments on commit 7f7bedb

Please sign in to comment.