frontend: resize heading pictures as thumb file
This commit is contained in:
parent
b387f011d8
commit
0bc42282aa
4 changed files with 14 additions and 4 deletions
|
@ -57,7 +57,7 @@ func resizePicture(importedPath string, rect image.Rectangle) error {
|
|||
dst := image.NewRGBA(rect)
|
||||
draw.CatmullRom.Scale(dst, rect, src, src.Bounds(), draw.Over, nil)
|
||||
|
||||
dstFile, err := os.Create(importedPath)
|
||||
dstFile, err := os.Create(strings.TrimSuffix(importedPath, ".jpg") + ".thumb.jpg")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -66,6 +66,16 @@ func resizePicture(importedPath string, rect image.Rectangle) error {
|
|||
if err = jpeg.Encode(dstFile, dst, &jpeg.Options{100}); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
dstFile, err := os.Create(strings.TrimSuffix(importedPath, ".jpg") + ".thumb.jpg")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer dstFile.Close()
|
||||
|
||||
if err = jpeg.Encode(dstFile, src, &jpeg.Options{100}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
Reference in a new issue