From 3a7ef4e15324c439d09b5eb7b8aa17f05a567d4a Mon Sep 17 00:00:00 2001 From: xieyg7919 Date: Tue, 7 Sep 2021 17:06:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A1=B9=E7=9B=AE=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=E4=B8=8A=E4=BC=A0=E7=9A=84BUG=201.BookController.go?= =?UTF-8?q?=E4=B8=AD344=E8=A1=8C=EF=BC=8C=E6=8B=BC=E6=8E=A5=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E5=9B=BE=E7=89=87=E4=BF=9D=E5=AD=98=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E6=97=B6=E6=9C=AA=E6=8B=BC=E6=8E=A5working=20directory=202.gra?= =?UTF-8?q?phics=E7=9B=AE=E5=BD=95=E4=B8=8Bcopy.go=E6=96=87=E4=BB=B611?= =?UTF-8?q?=E8=A1=8C=EF=BC=8CImageCopy=E6=96=B9=E6=B3=95=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?image.Paletted=E7=B1=BB=E5=9E=8B=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/BookController.go | 3 ++- graphics/copy.go | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/controllers/BookController.go b/controllers/BookController.go index 669d3a29..ff78b56e 100644 --- a/controllers/BookController.go +++ b/controllers/BookController.go @@ -340,7 +340,8 @@ func (c *BookController) UploadCover() { fileName := "cover_" + strconv.FormatInt(time.Now().UnixNano(), 16) //附件路径按照项目组织 - filePath := filepath.Join("uploads", book.Identify, "images", fileName+ext) +// filePath := filepath.Join("uploads", book.Identify, "images", fileName+ext) + filePath := filepath.Join(conf.WorkingDirectory, "uploads", book.Identify, "images", fileName+ext) path := filepath.Dir(filePath) diff --git a/graphics/copy.go b/graphics/copy.go index 0e4c7d14..3f4ec7bb 100644 --- a/graphics/copy.go +++ b/graphics/copy.go @@ -18,6 +18,8 @@ func ImageCopy(src image.Image, x, y, w, h int) (image.Image, error) { subImg = rgbImg.SubImage(image.Rect(x, y, x+w, y+h)).(*image.RGBA) //图片裁剪x0 y0 x1 y1 } else if rgbImg, ok := src.(*image.NRGBA); ok { subImg = rgbImg.SubImage(image.Rect(x, y, x+w, y+h)).(*image.NRGBA) //图片裁剪x0 y0 x1 y1 + } else if rgbImg, ok := src.(*image.Paletted); ok { + subImg = rgbImg.SubImage(image.Rect(x, y, x+w, y+h)).(*image.Paletted) //图片裁剪x0 y0 x1 y1 } else { return subImg, errors.New("图片解码失败")