diff --git a/service/imaging/processor_default.go b/service/imaging/processor_default.go index 2f5f9085b..addef26b1 100644 --- a/service/imaging/processor_default.go +++ b/service/imaging/processor_default.go @@ -87,7 +87,7 @@ func (p *defaultProcessor) FitAnimationGIF(srcFile io.Reader, width, height int) } // 画像が十分小さければスキップ if srcWidth <= width && srcHeight <= height { - return imaging2.GifToBytesReader(src), nil + return imaging2.GifToBytesReader(src) } // 元の比率を保つよう調整 @@ -117,7 +117,7 @@ func (p *defaultProcessor) FitAnimationGIF(srcFile io.Reader, width, height int) dst.Image = append(dst.Image, d) } - return imaging2.GifToBytesReader(src), nil + return imaging2.GifToBytesReader(src) } func (p *defaultProcessor) WaveformMp3(src io.ReadSeeker, width, height int) (r io.Reader, err error) { diff --git a/utils/imaging/gif.go b/utils/imaging/gif.go index aa8575a51..d11b3f7a1 100644 --- a/utils/imaging/gif.go +++ b/utils/imaging/gif.go @@ -6,10 +6,10 @@ import ( ) // GifToBytesReader GIF画像を*bytes.Readerに書き出します -func GifToBytesReader(src *gif.GIF) *bytes.Reader { +func GifToBytesReader(src *gif.GIF) (*bytes.Reader, error) { buf := new(bytes.Buffer) if err := gif.EncodeAll(buf, src); err != nil { - panic(err) + return nil, err } - return bytes.NewReader(buf.Bytes()) + return bytes.NewReader(buf.Bytes()), nil }