This commit is contained in:
@@ -68,6 +68,9 @@ func (rc *shopItemController) GetById(c *gin.Context) {
|
||||
ReplyOK(c, shopItem)
|
||||
}
|
||||
|
||||
// this currently creates quite big preview images
|
||||
// workaround is running the following command in the uploads folder:
|
||||
// for file in *.png; do convert "$file" -resize 35% "$file"; done
|
||||
func (rc *shopItemController) NewShopItemFromForm(ctx *gin.Context) (models.ShopItem, error) {
|
||||
defaultImagePath := "static/img/zine.jpg"
|
||||
name := ctx.PostForm("name")
|
||||
@@ -106,6 +109,14 @@ func (rc *shopItemController) NewShopItemFromForm(ctx *gin.Context) (models.Shop
|
||||
if err != nil {
|
||||
fmt.Println("Error during pdftoppm: ", err.Error())
|
||||
}
|
||||
|
||||
cmd2 := exec.Command("convert", dstImage, "-resize", "35%", dstImage)
|
||||
_, err = cmd2.Output()
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("Error during resizing preview image: ", err.Error())
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
@@ -365,6 +376,13 @@ func (rc *shopItemController) AddItemsHandler(c *gin.Context) {
|
||||
fmt.Println("Error during pdftoppm: ", err.Error())
|
||||
}
|
||||
|
||||
cmd2 := exec.Command("convert", dstImage, "-resize", "35%", dstImage)
|
||||
_, err = cmd2.Output()
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("Error during resizing preview image: ", err.Error())
|
||||
}
|
||||
|
||||
category, err := models.ParseCategory("Zine")
|
||||
if err != nil {
|
||||
errorHandler(err)
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
go
|
||||
gotools
|
||||
poppler_utils #get first pdf page to png
|
||||
imagemagick
|
||||
tailwindcss
|
||||
];
|
||||
};
|
||||
@@ -71,6 +72,7 @@
|
||||
environment.systemPackages = [
|
||||
zineshop-pkg
|
||||
pkgs.poppler_utils #get first pdf page to png
|
||||
pkgs.imagemagick
|
||||
];
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
@@ -100,7 +102,7 @@
|
||||
WorkingDirectory = "/var/lib/zineshop";
|
||||
ExecStart = pkgs.writeScript "start-zineshop" ''
|
||||
#! ${pkgs.bash}/bin/bash
|
||||
PATH="$PATH:${lib.makeBinPath [ pkgs.poppler_utils ]}"
|
||||
PATH="$PATH:${lib.makeBinPath [ pkgs.poppler_utils pkgs.imagemagick ]}"
|
||||
${zineshop-pkg}/bin/zineshop
|
||||
'';
|
||||
Restart = "on-failure";
|
||||
|
||||
Reference in New Issue
Block a user