From 5ed55c387cc8e4afae5a77e053ec60a52ccc99c3 Mon Sep 17 00:00:00 2001 From: Antoni Sawicki Date: Tue, 2 Jul 2024 02:35:48 -0700 Subject: [PATCH] todo image type based on form value --- txt.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/txt.go b/txt.go index bfacdc0..9aeaa06 100644 --- a/txt.go +++ b/txt.go @@ -116,6 +116,7 @@ func (t *astTransformer) Transform(node *ast.Document, reader text.Reader, pc pa link.Destination = append([]byte("?t=txt&url="), link.Destination...) } if img, ok := n.(*ast.Image); ok && entering { + // TODO: dynamic extension based on form value id := fmt.Sprintf("txt%05d.gif", rand.Intn(99999)) // BUG: atomic.AddInt64 or something that ever increases - time based? err := grabImage(id, string(img.Destination)) // TODO: use goroutines with waitgroup if err != nil { @@ -175,6 +176,7 @@ func imgServerZ(w http.ResponseWriter, r *http.Request) { w.(http.Flusher).Flush() } +// TODO set JPG/GIF/PNG type based on form... func smallGif(src []byte) ([]byte, error) { t := http.DetectContentType(src) var err error @@ -197,6 +199,7 @@ func smallGif(src []byte) ([]byte, error) { img = resize.Thumbnail(uint(*txtImgSize), uint(*txtImgSize), img, resize.NearestNeighbor) var gifBuf bytes.Buffer err = gif.Encode(&gifBuf, gifPalette(img, 216), &gif.Options{}) + //err =jpeg.Encode(&gifBuf, img, &jpeg.Options{Quality: 50}) if err != nil { return nil, fmt.Errorf("gif encode problem: %v", err) }