all repos — honk @ 4eb6a4a578b54d63912faf6dc1aed71bbdfc8c46

my fork of honk

bloaty pig posters and their images of unusual size
Ted Unangst tedu@tedunangst.com
Fri, 26 Apr 2019 17:01:17 -0400
commit

4eb6a4a578b54d63912faf6dc1aed71bbdfc8c46

parent

d2a62e2973d7b73505635bdb170a5abaf34014ce

2 files changed, 13 insertions(+), 5 deletions(-)

jump to
M activity.goactivity.go

@@ -22,6 +22,7 @@ "crypto/rsa"

"database/sql" "encoding/json" "fmt" + "image" "io" "log" "net/http"

@@ -217,7 +218,17 @@ io.Copy(&buf, resp.Body)

xid := xfiltrate() - res, err := stmtSaveFile.Exec(xid, name, url, media, buf.Bytes()) + data := buf.Bytes() + if strings.HasPrefix(media, "image") { + img, format, err := image.Decode(&buf) + if err != nil { + log.Printf("unable to decode image: %s", err) + return nil + } + data, format, err = vacuumwrap(img, format) + media = "image/" + format + } + res, err := stmtSaveFile.Exec(xid, name, url, media, data) if err != nil { log.Printf("error saving file %s: %s", url, err) return nil
M honk.gohonk.go

@@ -24,9 +24,6 @@ "fmt"

"html" "html/template" "image" - _ "image/gif" - _ "image/jpeg" - _ "image/png" "io" "log" notrand "math/rand"

@@ -1129,7 +1126,7 @@ return

} db := opendatabase() db.Exec("insert into zonkers (userid, name, wherefore) values (?, ?, ?)", - userinfo.UserID, name, wherefore) + userinfo.UserID, name, wherefore) if wherefore == "zonker" || wherefore == "zurl" { bitethethumbs() }