diff --git a/main.go b/main.go index 5853e3b..b6c9bab 100644 --- a/main.go +++ b/main.go @@ -96,7 +96,6 @@ func serveMarkdown(w http.ResponseWriter, r *http.Request, paths ...string) { pathDir = pathDir[:lastSlash] } // Markdown uses the path to generate the correct paths for resized images - log.Print(paths[i], "->", pathDir) html := Markdown(b, pathDir) w.Write(html) } diff --git a/markdown.go b/markdown.go index 48ab165..954f7ea 100644 --- a/markdown.go +++ b/markdown.go @@ -15,7 +15,6 @@ package main import ( "bytes" "fmt" - "log" "regexp" "sort" "strings" @@ -33,7 +32,6 @@ import ( // Markdown renders GitHub Flavored Markdown text. func Markdown(text []byte, path string) []byte { - log.Print("markdown " + path) const htmlFlags = 0 renderer := &renderer{ Html: blackfriday.HtmlRenderer(htmlFlags, "", "").(*blackfriday.Html), path: path} @@ -120,7 +118,7 @@ func (r *renderer) Image(out *bytes.Buffer, link []byte, title []byte, alt []byt writeSource := func() { out.WriteString("") + out.WriteString("\" media=\"(min-width: 800px)\">") } // link to outside of this website if bytes.HasPrefix(link, []byte("http")) { diff --git a/resize.go b/resize.go index 4fcdfd4..9a18f33 100644 --- a/resize.go +++ b/resize.go @@ -39,9 +39,10 @@ func Resize(maxWidth uint, h http.Handler) http.Handler { rw.Write([]byte("error while decoding png: " + err.Error())) return } - resizedImage := resize.Thumbnail(maxWidth, 0, image, resize.Lanczos3) + resizedImage := resize.Thumbnail(2*maxWidth, 100000, image, resize.NearestNeighbor) resizedBuf := new(bytes.Buffer) - if encodeErr := png.Encode(resizedBuf, resizedImage); encodeErr != nil { + encoder := png.Encoder{CompressionLevel: png.BestCompression} + if encodeErr := encoder.Encode(resizedBuf, resizedImage); encodeErr != nil { rw.WriteHeader(501) rw.Write([]byte("error while encoding png: " + err.Error())) return