mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-12-14 01:14:29 +01:00
Fix variable names
This commit is contained in:
parent
e554d048c9
commit
24f7f353e4
1 changed files with 7 additions and 7 deletions
14
portal.go
14
portal.go
|
@ -2831,16 +2831,16 @@ func (img *PaddedImage) At(x, y int) color.Color {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (portal *Portal) convertToWebP(img []byte) ([]byte, error) {
|
func (portal *Portal) convertToWebP(img []byte) ([]byte, error) {
|
||||||
webpDecoded, _, err := image.Decode(bytes.NewReader(img))
|
decodedImg, _, err := image.Decode(bytes.NewReader(img))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to decode image: %w", err)
|
return nil, fmt.Errorf("failed to decode image: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
bounds := webpDecoded.Bounds()
|
bounds := decodedImg.Bounds()
|
||||||
width, height := bounds.Dx(), bounds.Dy()
|
width, height := bounds.Dx(), bounds.Dy()
|
||||||
if width != height {
|
if width != height {
|
||||||
paddedImg := &PaddedImage{
|
paddedImg := &PaddedImage{
|
||||||
Image: webpDecoded,
|
Image: decodedImg,
|
||||||
OffsetX: bounds.Min.Y,
|
OffsetX: bounds.Min.Y,
|
||||||
OffsetY: bounds.Min.X,
|
OffsetY: bounds.Min.X,
|
||||||
}
|
}
|
||||||
|
@ -2851,15 +2851,15 @@ func (portal *Portal) convertToWebP(img []byte) ([]byte, error) {
|
||||||
paddedImg.Size = height
|
paddedImg.Size = height
|
||||||
paddedImg.OffsetX -= (paddedImg.Size - width) / 2
|
paddedImg.OffsetX -= (paddedImg.Size - width) / 2
|
||||||
}
|
}
|
||||||
webpDecoded = paddedImg
|
decodedImg = paddedImg
|
||||||
}
|
}
|
||||||
|
|
||||||
var pngBuffer bytes.Buffer
|
var webpBuffer bytes.Buffer
|
||||||
if err = webp.Encode(&pngBuffer, webpDecoded, nil); err != nil {
|
if err = webp.Encode(&webpBuffer, decodedImg, nil); err != nil {
|
||||||
return nil, fmt.Errorf("failed to encode png image: %w", err)
|
return nil, fmt.Errorf("failed to encode png image: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return pngBuffer.Bytes(), nil
|
return webpBuffer.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (portal *Portal) preprocessMatrixMedia(ctx context.Context, sender *User, relaybotFormatted bool, content *event.MessageEventContent, eventID id.EventID, mediaType whatsmeow.MediaType) (*MediaUpload, error) {
|
func (portal *Portal) preprocessMatrixMedia(ctx context.Context, sender *User, relaybotFormatted bool, content *event.MessageEventContent, eventID id.EventID, mediaType whatsmeow.MediaType) (*MediaUpload, error) {
|
||||||
|
|
Loading…
Reference in a new issue