Skip to content

Commit

Permalink
fix: fix format is none, output image format error
Browse files Browse the repository at this point in the history
when the format in request is set 'none', do not change the output image's format, keep format same
with origin image.
  • Loading branch information
zhoukk committed May 11, 2019
1 parent 241b89d commit 5d124f7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions image.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,14 @@ func (image *KimgImagick) Convert(data []byte, req KimgRequest) ([]byte, error)
}
image.ctx.Logger.Debug("SetImageCompressionQuality %d", req.Quality)

err = mw.SetImageFormat(req.Format)
if err != nil {
image.ctx.Logger.Warn("SetImageFormat %s, err: %s", req.Format, err)
return nil, err
if "none" != req.Format {
err = mw.SetImageFormat(req.Format)
if err != nil {
image.ctx.Logger.Warn("SetImageFormat %s, err: %s", req.Format, err)
return nil, err
}
image.ctx.Logger.Debug("SetImageFormat %s", req.Format)
}
image.ctx.Logger.Debug("SetImageFormat %s", req.Format)

newData := mw.GetImageBlob()
if newData == nil || len(newData) == 0 {
Expand Down

0 comments on commit 5d124f7

Please sign in to comment.