mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-01-18 06:30:07 +08:00
Merge pull request #114 from yanyiwu/master
log image Decode error for some kind of pictures
This commit is contained in:
commit
ce676ee100
@ -7,6 +7,7 @@ import (
|
|||||||
"image/jpeg"
|
"image/jpeg"
|
||||||
"image/png"
|
"image/png"
|
||||||
|
|
||||||
|
"github.com/chrislusf/weed-fs/go/glog"
|
||||||
"github.com/disintegration/imaging"
|
"github.com/disintegration/imaging"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -14,7 +15,8 @@ func Resized(ext string, data []byte, width, height int) (resized []byte, w int,
|
|||||||
if width == 0 && height == 0 {
|
if width == 0 && height == 0 {
|
||||||
return data, 0, 0
|
return data, 0, 0
|
||||||
}
|
}
|
||||||
if srcImage, _, err := image.Decode(bytes.NewReader(data)); err == nil {
|
srcImage, _, err := image.Decode(bytes.NewReader(data))
|
||||||
|
if err == nil {
|
||||||
bounds := srcImage.Bounds()
|
bounds := srcImage.Bounds()
|
||||||
var dstImage *image.NRGBA
|
var dstImage *image.NRGBA
|
||||||
if bounds.Dx() > width && width != 0 || bounds.Dy() > height && height != 0 {
|
if bounds.Dx() > width && width != 0 || bounds.Dy() > height && height != 0 {
|
||||||
@ -37,6 +39,8 @@ func Resized(ext string, data []byte, width, height int) (resized []byte, w int,
|
|||||||
gif.Encode(&buf, dstImage, nil)
|
gif.Encode(&buf, dstImage, nil)
|
||||||
}
|
}
|
||||||
return buf.Bytes(), dstImage.Bounds().Dx(), dstImage.Bounds().Dy()
|
return buf.Bytes(), dstImage.Bounds().Dx(), dstImage.Bounds().Dy()
|
||||||
|
} else {
|
||||||
|
glog.Error(err)
|
||||||
}
|
}
|
||||||
return data, 0, 0
|
return data, 0, 0
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user