fix(back) remake file
This commit is contained in:
@@ -3,3 +3,6 @@ bin
|
||||
main
|
||||
.git
|
||||
.env
|
||||
uploads/
|
||||
uploads_backups/
|
||||
*.md
|
||||
|
||||
@@ -18,7 +18,6 @@ FROM alpine:latest
|
||||
WORKDIR /root/
|
||||
|
||||
COPY --from=builder /app/main .
|
||||
COPY --from=builder /app/uploads ./uploads
|
||||
|
||||
EXPOSE 8090
|
||||
CMD ["./main"]
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/disintegration/imaging"
|
||||
)
|
||||
|
||||
func main() {
|
||||
path := "./uploads/items/background.png"
|
||||
|
||||
img, err := imaging.Open(path)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
resized := imaging.Resize(img, 1920, 0, imaging.Lanczos)
|
||||
|
||||
newPath := "./uploads/items/background.jpg"
|
||||
|
||||
err = imaging.Save(resized, newPath, imaging.JPEGQuality(82))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Println("Готово")
|
||||
}
|
||||
@@ -26,7 +26,7 @@ func GetItem(c *gin.Context) {
|
||||
if item.AvatarURL != "" {
|
||||
item.AvatarURL = fmt.Sprintf("/static/items/%s", item.AvatarURL)
|
||||
} else {
|
||||
item.AvatarURL = fmt.Sprintf("/static/items/background.png")
|
||||
item.AvatarURL = fmt.Sprintf("/static/items/background.jpg")
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, item)
|
||||
@@ -44,7 +44,7 @@ func GetAllItems(c *gin.Context) {
|
||||
if items[i].AvatarURL != "" {
|
||||
items[i].AvatarURL = fmt.Sprintf("/static/items/%s", items[i].AvatarURL)
|
||||
} else {
|
||||
items[i].AvatarURL = fmt.Sprintf("/static/items/background.png")
|
||||
items[i].AvatarURL = fmt.Sprintf("/static/items/background.jpg")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 239 KiB |
Reference in New Issue
Block a user