From eb8c9c393d110b7771b08ca28bef8641d4105b36 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Fri, 5 Jan 2024 01:10:13 -0300 Subject: [PATCH] get rid of twitter messy inscriptions over our image. --- render_event.go | 5 ++--- render_image.go | 8 +++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/render_event.go b/render_event.go index 6d15779..fc96a56 100644 --- a/render_event.go +++ b/render_event.go @@ -335,9 +335,8 @@ func renderEvent(w http.ResponseWriter, r *http.Request) { }) case Note: if style == StyleTwitter { - // twitter only uses one title, so we ensure it is this - // we can't set this for other platforms as some will reuse stuff from twitter-specific tags - opengraph.SingleTitle = "by " + data.authorShort + " at " + humanDate(data.event.CreatedAt) + // twitter has started sprinkling this over our image, so let's make it invisible + opengraph.SingleTitle = string(INVISIBLE_SPACE) } if opengraph.BigImage == "" && style != StyleTwitter && strings.HasSuffix(opengraph.Text, opengraph.Image) { diff --git a/render_image.go b/render_image.go index c053c11..0894c55 100644 --- a/render_image.go +++ b/render_image.go @@ -94,7 +94,6 @@ func drawImage(paragraphs []string, style Style, metadata sdk.ProfileMetadata, d width := 700 height := 525 paddingLeft := 25 - barExtraPadding := 0 gradientRectHeight := 140 switch style { case StyleTelegram: @@ -102,7 +101,6 @@ func drawImage(paragraphs []string, style Style, metadata sdk.ProfileMetadata, d width -= 10 case StyleTwitter: height = width * 268 / 512 - barExtraPadding = 105 } img := gg.NewContext(width, height) @@ -150,17 +148,17 @@ func drawImage(paragraphs []string, style Style, metadata sdk.ProfileMetadata, d } // draw author's name - authorTextX := paddingLeft + barExtraPadding + authorTextX := paddingLeft if metadata.Picture != "" { authorImage, err := fetchImageFromURL(metadata.Picture) if err == nil { resizedAuthorImage := resize.Resize(uint(barHeight-20), uint(barHeight-20), roundImage(cropToSquare(authorImage)), resize.Lanczos3) - img.DrawImage(resizedAuthorImage, paddingLeft+barExtraPadding, height-barHeight+10) + img.DrawImage(resizedAuthorImage, paddingLeft, height-barHeight+10) authorTextX += 65 } } authorTextY := height - barHeight + 15 - authorMaxWidth := width/2.0 - paddingLeft*2 - barExtraPadding + authorMaxWidth := width/2.0 - paddingLeft*2 img.SetColor(color.White) textImg = drawText([]string{metadata.ShortName()}, fontSize, width, barHeight) img.DrawImage(textImg, authorTextX, authorTextY)