From 15da1cc38cb90424dfbcb4aa8466733bdcd58622 Mon Sep 17 00:00:00 2001 From: everpcpc Date: Fri, 18 Oct 2024 04:46:07 +0000 Subject: [PATCH] chore: upgrade imagemagick --- go.mod | 2 +- go.sum | 4 ++-- telegram/command.go | 11 ++++++++--- yubari.go | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 8a536d0..da5575b 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/stretchr/testify v1.8.1 golang.org/x/net v0.17.0 golang.org/x/text v0.13.0 - gopkg.in/gographics/imagick.v2 v2.6.0 + gopkg.in/gographics/imagick.v3 v3.7.1 ) require ( diff --git a/go.sum b/go.sum index 73cc6cf..a81c81f 100644 --- a/go.sum +++ b/go.sum @@ -203,8 +203,8 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/gographics/imagick.v2 v2.6.0 h1:ewRsUQk3QkjGumERlndbFn/kTYRjyMaPY5gxwpuAhik= -gopkg.in/gographics/imagick.v2 v2.6.0/go.mod h1:/QVPLV/iKdNttRKthmDkeeGg+vdHurVEPc8zkU0XgBk= +gopkg.in/gographics/imagick.v3 v3.7.1 h1:YS5haF8HrPzDJJ2+o6ciLgdaUwYqI5wlSJpg7WcnTIs= +gopkg.in/gographics/imagick.v3 v3.7.1/go.mod h1:+Q9nyA2xRZXrDyTtJ/eko+8V/5E7bWYs08ndkZp8UmA= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/telegram/command.go b/telegram/command.go index b128adb..d8738fd 100644 --- a/telegram/command.go +++ b/telegram/command.go @@ -11,7 +11,7 @@ import ( "yubari/pixiv" tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5" - "gopkg.in/gographics/imagick.v2/imagick" + "gopkg.in/gographics/imagick.v3/imagick" ) func onStart(b *Bot, message *tgbotapi.Message) { @@ -140,15 +140,20 @@ func onPixivNoArgs(b *Bot, message *tgbotapi.Message) { width := mw.GetImageWidth() height := mw.GetImageHeight() - err = mw.ResizeImage(640, 640*height/width, 0, 1) + err = mw.ResizeImage(640, 640*height/width, imagick.FILTER_BOX) if err != nil { b.logger.Errorf("resize image failed: %s", err) return } + blob, err := mw.GetImageBlob() + if err != nil { + b.logger.Errorf("get image blob failed: %s", err) + return + } msg := tgbotapi.NewPhoto(message.Chat.ID, tgbotapi.FileBytes{ Name: fileName, - Bytes: mw.GetImageBlob(), + Bytes: blob, }) msg.ParseMode = tgbotapi.ModeHTML msg.Caption = fmt.Sprintf( diff --git a/yubari.go b/yubari.go index 9679b58..ac9c761 100644 --- a/yubari.go +++ b/yubari.go @@ -8,7 +8,7 @@ import ( "github.com/go-redis/redis" bt "github.com/ikool-cn/gobeanstalk-connection-pool" meilisearch "github.com/meilisearch/meilisearch-go" - "gopkg.in/gographics/imagick.v2/imagick" + "gopkg.in/gographics/imagick.v3/imagick" "yubari/mastodon" "yubari/pixiv"