GOWA - WhatsApp REST API with support for UI, Multi Account, Webhooks, and MCP, and Chatwoot. Built with Golang for efficient memory use.
Go botgogolanggolang-whatsappgolang-whatsapp-apirestrest-apiwhatsappwhatsapp-apiwhatsapp-api-gowhatsapp-multi-devicewhatsapp-web-multi-device
feat: remove vips dependency (#136)
Aldino Kemal21a451c542d2
diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.ymlindex cefdec9e..2cb61e47 100644--- a/.github/workflows/release-linux.yml+++ b/.github/workflows/release-linux.yml@@ -15,10 +15,6 @@ jobs:environment: productionsteps:- uses: actions/checkout@v4- - name: Ubuntu update package- run: |- sudo apt -y update- sudo apt -y install libvips-dev- name: Golang Installationuses: actions/setup-go@v4with:@@ -39,10 +35,6 @@ jobs:environment: productionsteps:- uses: actions/checkout@v4- - name: Ubuntu update package- run: |- sudo apt -y update- sudo apt -y install libvips-dev- name: Golang Installationuses: actions/setup-go@v4with:diff --git a/.github/workflows/release-mac.yml b/.github/workflows/release-mac.ymlindex eeeec298..a30489fa 100644--- a/.github/workflows/release-mac.yml+++ b/.github/workflows/release-mac.yml@@ -15,9 +15,6 @@ jobs:environment: productionsteps:- uses: actions/checkout@v4- - name: Install libvips- run: |- brew install vips- name: Golang Installationuses: actions/setup-go@v4with:diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.ymlindex 45679466..12e738e7 100644--- a/.github/workflows/release-windows.yml+++ b/.github/workflows/release-windows.yml@@ -15,30 +15,12 @@ jobs:environment: productionsteps:- uses: actions/checkout@v4- - name: Install pkgconfig- uses: crazy-max/ghaction-chocolatey@v3- with:- ref: ${{ github.ref_name }}- args: install pkgconfiglite --allow-empty-checksums- - name: Vips download- run: curl -LO https://github.com/libvips/build-win64-mxe/releases/download/v8.12.0/vips-dev-w64-all-8.12.0.zip- - name: Vips Extract- run: |- 7z x .\vips-dev-w64-all-8.12.0.zip- - name: Vips add to path- shell: pwsh- run: |- Copy-Item -Path ${{ github.workspace }}\vips-dev-8.12\lib\pkgconfig\* -Destination C:/Strawberry/c/lib/pkgconfig -force -recurse- Copy-Item -Path ${{ github.workspace }}\vips-dev-8.12\bin\* -Destination C:/Strawberry/c/bin -force -recurse- Copy-Item -Path ${{ github.workspace }}\vips-dev-8.12\include\* -Destination C:/Strawberry/c/include -force -recurse- name: Golang Installationuses: actions/setup-go@v4with:go-version: '1.21'- name: Golang buildrun: |- [Environment]::SetEnvironmentVariable("Path", $env:Path + ";${{ github.workspace }}\vips-dev-8.12\bin")- [Environment]::SetEnvironmentVariable("PKG_CONFIG_PATH", "${{ github.workspace }}\vips-dev-8.12\lib\pkgconfig")cd src && go build -o windows-amd64.exe- name: Deploy artifact to release ${{ github.ref_name }}uses: AButler/[email protected]diff --git a/docker/golang.Dockerfile b/docker/golang.Dockerfileindex d25f9235..2b849059 100644--- a/docker/golang.Dockerfile+++ b/docker/golang.Dockerfile@@ -2,7 +2,7 @@# STEP 1 build executable binary############################FROM golang:1.21.5-alpine3.19 AS builder-RUN apk update && apk add --no-cache vips-dev gcc musl-dev gcompat ffmpeg+RUN apk update && apk add --no-cache gcc musl-dev gcompatWORKDIR /whatsappCOPY ./src .@@ -15,7 +15,7 @@ RUN go build -o /app/whatsapp## STEP 2 build a smaller image#############################FROM alpine:3.19-RUN apk update && apk add --no-cache vips-dev ffmpeg+RUN apk update && apk add --no-cache ffmpegWORKDIR /app# Copy compiled from builder.COPY --from=builder /app/whatsapp /app/whatsappdiff --git a/readme.md b/readme.mdindex 1221beba..20b24cff 100644--- a/readme.md+++ b/readme.md@@ -38,17 +38,14 @@ Now that we support ARM64 for Linux:### Required (without docker)- Mac OS:- - `brew install vips`- `brew install ffmpeg`- `export CGO_CFLAGS_ALLOW="-Xpreprocessor"`- Linux:- `sudo apt update`- - `sudo apt install libvips-dev`- `sudo apt install ffmpeg`- Windows (not recomended, prefer using [WSL](https://docs.microsoft.com/en-us/windows/wsl/install)):- - install vips library, or you can check here https://www.libvips.org/install.html- install ffmpeg, download [here](https://www.ffmpeg.org/download.html#build-windows)- - add to vips & ffmpg to [environment variable](https://www.google.com/search?q=windows+add+to+environment+path)+ - add to ffmpeg to [environment variable](https://www.google.com/search?q=windows+add+to+environment+path)### How to usediff --git a/src/cmd/root.go b/src/cmd/root.goindex a19d2c39..1fcc79bb 100644--- a/src/cmd/root.go+++ b/src/cmd/root.go@@ -66,7 +66,8 @@ func runRest(_ *cobra.Command, _ []string) {return token != nil})app := fiber.New(fiber.Config{- Views: engine,+ Views: engine,+ BodyLimit: int(config.WhatsappSettingMaxVideoSize),})app.Static("/statics", "./statics")app.Use("/components", filesystem.New(filesystem.Config{diff --git a/src/go.mod b/src/go.modindex b8a069af..977e4a28 100644--- a/src/go.mod+++ b/src/go.mod@@ -4,13 +4,13 @@ go 1.21require (github.com/PuerkitoBio/goquery v1.9.1+ github.com/disintegration/imaging v1.6.2github.com/dustin/go-humanize v1.0.1github.com/go-ozzo/ozzo-validation/v4 v4.3.0github.com/gofiber/fiber/v2 v2.52.4github.com/gofiber/template/html/v2 v2.1.1github.com/gofiber/websocket/v2 v2.2.1github.com/google/uuid v1.6.0- github.com/h2non/bimg v1.1.9github.com/mattn/go-sqlite3 v1.14.22github.com/sirupsen/logrus v1.9.3github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e@@ -33,7 +33,7 @@ require (github.com/gofiber/utils v1.1.0 // indirectgithub.com/gorilla/websocket v1.5.1 // indirectgithub.com/inconshreveable/mousetrap v1.1.0 // indirect- github.com/klauspost/compress v1.17.7 // indirect+ github.com/klauspost/compress v1.17.8 // indirectgithub.com/kr/pretty v0.1.0 // indirectgithub.com/mattn/go-colorable v0.1.13 // indirectgithub.com/mattn/go-isatty v0.0.20 // indirect@@ -45,10 +45,11 @@ require (github.com/spf13/pflag v1.0.5 // indirectgithub.com/valyala/bytebufferpool v1.0.0 // indirectgithub.com/valyala/tcplisten v1.0.0 // indirect- go.mau.fi/util v0.4.1 // indirect- golang.org/x/crypto v0.21.0 // indirect- golang.org/x/net v0.22.0 // indirect- golang.org/x/sys v0.18.0 // indirect+ go.mau.fi/util v0.4.2 // indirect+ golang.org/x/crypto v0.22.0 // indirect+ golang.org/x/image v0.15.0 // indirect+ golang.org/x/net v0.24.0 // indirect+ golang.org/x/sys v0.19.0 // indirectgolang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirectgopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirectgopkg.in/yaml.v3 v3.0.1 // indirectdiff --git a/src/go.sum b/src/go.sumindex 99cd5b94..7db83664 100644--- a/src/go.sum+++ b/src/go.sum@@ -14,6 +14,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tgithub.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=+github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=+github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=github.com/fasthttp/websocket v1.5.8 h1:k5DpirKkftIF/w1R8ZzjSgARJrs54Je9YJK37DL/Ah8=@@ -21,8 +23,6 @@ github.com/fasthttp/websocket v1.5.8/go.mod h1:d08g8WaT6nnyvg9uMm8K9zMYyDjfKyj31github.com/go-ozzo/ozzo-validation/v4 v4.3.0 h1:byhDUpfEwjsVQb1vBunvIjh2BHQ9ead57VkAEY4V+Es=github.com/go-ozzo/ozzo-validation/v4 v4.3.0/go.mod h1:2NKgrcHl3z6cJs+3Oo940FPRiTzuqKbvfrL2RxCj6Ew=github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=-github.com/gofiber/fiber/v2 v2.52.2 h1:b0rYH6b06Df+4NyrbdptQL8ifuxw/Tf2DgfkZkDaxEo=-github.com/gofiber/fiber/v2 v2.52.2/go.mod h1:KEOE+cXMhXG0zHc9d8+E38hoX+ZN7bhOtgeF2oT6jrQ=github.com/gofiber/fiber/v2 v2.52.4 h1:P+T+4iK7VaqUsq2PALYEfBBo6bJZ4q3FP8cZ84EggTM=github.com/gofiber/fiber/v2 v2.52.4/go.mod h1:KEOE+cXMhXG0zHc9d8+E38hoX+ZN7bhOtgeF2oT6jrQ=github.com/gofiber/template v1.8.3 h1:hzHdvMwMo/T2kouz2pPCA0zGiLCeMnoGsQZBTSYgZxc=@@ -39,12 +39,10 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=-github.com/h2non/bimg v1.1.9 h1:WH20Nxko9l/HFm4kZCA3Phbgu2cbHvYzxwxn9YROEGg=-github.com/h2non/bimg v1.1.9/go.mod h1:R3+UiYwkK4rQl6KVFTOFJHitgLbZXBZNFh2cv3AEbp8=github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=-github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg=-github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=+github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU=+github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=@@ -94,20 +92,17 @@ github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7Fwgithub.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=go.mau.fi/libsignal v0.1.0 h1:vAKI/nJ5tMhdzke4cTK1fb0idJzz1JuEIpmjprueC+c=go.mau.fi/libsignal v0.1.0/go.mod h1:R8ovrTezxtUNzCQE5PH30StOQWWeBskBsWE55vMfY9I=-go.mau.fi/util v0.4.0 h1:S2X3qU4pUcb/vxBRfAuZjbrR9xVMAXSjQojNBLPBbhs=-go.mau.fi/util v0.4.0/go.mod h1:leeiHtgVBuN+W9aDii3deAXnfC563iN3WK6BF8/AjNw=-go.mau.fi/util v0.4.1 h1:3EC9KxIXo5+h869zDGf5OOZklRd/FjeVnimTwtm3owg=-go.mau.fi/util v0.4.1/go.mod h1:GjkTEBsehYZbSh2LlE6cWEn+6ZIZTGrTMM/5DMNlmFY=-go.mau.fi/whatsmeow v0.0.0-20240308162537-79d9175fa09b h1:Jk0/Lu6LdLD4kh0L9Q+06n7EefcS8ZDAKpwGeX7C4YQ=-go.mau.fi/whatsmeow v0.0.0-20240308162537-79d9175fa09b/go.mod h1:lQHbhaG/fI+6hfGqz5Vzn2OBJBEZ05H0kCP6iJXriN4=-go.mau.fi/whatsmeow v0.0.0-20240312193055-9b989e1cc696 h1:F9ytx1yzfoclCS4DoEqQb1M0E5XpcX2j5dX8bIZjGFE=-go.mau.fi/whatsmeow v0.0.0-20240312193055-9b989e1cc696/go.mod h1:lQHbhaG/fI+6hfGqz5Vzn2OBJBEZ05H0kCP6iJXriN4=+go.mau.fi/util v0.4.2 h1:RR3TOcRHmCF9Bx/3YG4S65MYfa+nV6/rn8qBWW4Mi30=+go.mau.fi/util v0.4.2/go.mod h1:PlAVfUUcPyHPrwnvjkJM9UFcPE7qGPDJqk+Oufa1Gtw=go.mau.fi/whatsmeow v0.0.0-20240327124018-350073db195c h1:a5O4nqmwUWvmC+27RUdefkuy5XzMOEUqR9ji+/BcHZA=go.mau.fi/whatsmeow v0.0.0-20240327124018-350073db195c/go.mod h1:kNI5foyzqd77d5HaWc1Jico6/rxtZ/UE8nr80hIsbIk=golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=-golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=-golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=+golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=+golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=+golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=+golang.org/x/image v0.15.0 h1:kOELfmgrmJlw4Cdb7g/QGuB3CvDrXbqEIww/pNtNBm8=+golang.org/x/image v0.15.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=@@ -115,8 +110,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9vgolang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=-golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=-golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=+golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=+golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=@@ -131,8 +126,8 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=-golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=-golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=+golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=+golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=diff --git a/src/services/send.go b/src/services/send.goindex 62edb461..f5b1b6ee 100644--- a/src/services/send.go+++ b/src/services/send.go@@ -11,8 +11,8 @@ import ("github.com/aldinokemal/go-whatsapp-web-multidevice/pkg/utils""github.com/aldinokemal/go-whatsapp-web-multidevice/pkg/whatsapp""github.com/aldinokemal/go-whatsapp-web-multidevice/validations"+ "github.com/disintegration/imaging"fiberUtils "github.com/gofiber/fiber/v2/utils"- "github.com/h2non/bimg""github.com/sirupsen/logrus""github.com/valyala/fasthttp""go.mau.fi/whatsmeow"@@ -107,37 +107,30 @@ func (service serviceSend) SendImage(ctx context.Context, request domainSend.Ima}deletedItems = append(deletedItems, oriImagePath)- // Generate thumbnail with smalled image- openThumbnailBuffer, err := bimg.Read(oriImagePath)+ /* Generate thumbnail with smalled image size */+ srcImage, err := imaging.Open(oriImagePath)if err != nil {- return response, pkgError.InternalServerError(fmt.Sprintf("failed to read image %v", err))+ return response, pkgError.InternalServerError(fmt.Sprintf("failed to open image %v", err))}++ // Resize Thumbnail+ resizedImage := imaging.Resize(srcImage, 100, 0, imaging.Lanczos)imageThumbnail = fmt.Sprintf("%s/thumbnails-%s", config.PathSendItems, request.Image.Filename)- thumbnailImage, err := bimg.NewImage(openThumbnailBuffer).Process(bimg.Options{Quality: 90, Width: 100, Embed: true})- if err != nil {- return response, err- }- err = bimg.Write(imageThumbnail, thumbnailImage)- if err != nil {- return response, err+ if err = imaging.Save(resizedImage, imageThumbnail); err != nil {+ return response, pkgError.InternalServerError(fmt.Sprintf("failed to save thumbnail %v", err))}deletedItems = append(deletedItems, imageThumbnail)if request.Compress {// Resize image- openImageBuffer, err := bimg.Read(oriImagePath)+ openImageBuffer, err := imaging.Open(oriImagePath)if err != nil {- return response, pkgError.InternalServerError(fmt.Sprintf("failed to read image %v", err))+ return response, pkgError.InternalServerError(fmt.Sprintf("failed to open image %v", err))}- newImage, err := bimg.NewImage(openImageBuffer).Process(bimg.Options{Quality: 90, Width: 600, Embed: true})- if err != nil {- return response, err- }-+ newImage := imaging.Resize(openImageBuffer, 600, 0, imaging.Lanczos)newImagePath := fmt.Sprintf("%s/new-%s", config.PathSendItems, request.Image.Filename)- err = bimg.Write(newImagePath, newImage)- if err != nil {- return response, err+ if err = imaging.Save(newImage, newImagePath); err != nil {+ return response, pkgError.InternalServerError(fmt.Sprintf("failed to save image %v", err))}deletedItems = append(deletedItems, newImagePath)imagePath = newImagePath@@ -258,6 +251,12 @@ func (service serviceSend) SendVideo(ctx context.Context, request domainSend.Vidreturn response, pkgError.InternalServerError(fmt.Sprintf("failed to store video in server %v", err))}+ // Check if ffmpeg is installed+ _, err = exec.LookPath("ffmpeg")+ if err != nil {+ return response, pkgError.InternalServerError("ffmpeg not installed")+ }+// Get thumbnail video with ffmpegthumbnailVideoPath := fmt.Sprintf("%s/%s", config.PathSendItems, generateUUID+".png")cmdThumbnail := exec.Command("ffmpeg", "-i", oriVideoPath, "-ss", "00:00:01.000", "-vframes", "1", thumbnailVideoPath)@@ -267,18 +266,14 @@ func (service serviceSend) SendVideo(ctx context.Context, request domainSend.Vid}// Resize Thumbnail- openImageBuffer, err := bimg.Read(thumbnailVideoPath)+ srcImage, err := imaging.Open(thumbnailVideoPath)if err != nil {- return response, pkgError.InternalServerError(fmt.Sprintf("failed to read thumbnail %v", err))+ return response, pkgError.InternalServerError(fmt.Sprintf("failed to open image %v", err))}- resize, err := bimg.NewImage(openImageBuffer).Process(bimg.Options{Quality: 90, Width: 600, Embed: true})- if err != nil {- return response, pkgError.InternalServerError(fmt.Sprintf("failed to resize thumbnail %v", err))- }- thumbnailResizeVideoPath := fmt.Sprintf("%s/%s", config.PathSendItems, generateUUID+"_resize.png")- err = bimg.Write(thumbnailResizeVideoPath, resize)- if err != nil {- return response, pkgError.InternalServerError(fmt.Sprintf("failed to create image thumbnail %v", err))+ resizedImage := imaging.Resize(srcImage, 100, 0, imaging.Lanczos)+ thumbnailResizeVideoPath := fmt.Sprintf("%s/thumbnails-%s", config.PathSendItems, generateUUID+".png")+ if err = imaging.Save(resizedImage, thumbnailResizeVideoPath); err != nil {+ return response, pkgError.InternalServerError(fmt.Sprintf("failed to save thumbnail %v", err))}deletedItems = append(deletedItems, thumbnailVideoPath)@@ -287,7 +282,7 @@ func (service serviceSend) SendVideo(ctx context.Context, request domainSend.Vidif request.Compress {compresVideoPath := fmt.Sprintf("%s/%s", config.PathSendItems, generateUUID+".mp4")- // Compress video with ffmpeg+cmdCompress := exec.Command("ffmpeg", "-i", oriVideoPath, "-strict", "-2", compresVideoPath)err = cmdCompress.Run()if err != nil {