get rid of twitter messy inscriptions over our image.

This commit is contained in:
fiatjaf
2024-01-05 01:10:13 -03:00
parent 7ad5ac2984
commit eb8c9c393d
2 changed files with 5 additions and 8 deletions

View File

@@ -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) {

View File

@@ -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)