Permalink
Browse files

simplified go example

  • Loading branch information...
1 parent d4ec96f commit 31407c766f0788c08dd78916fc3cf45ecb2e1e22 @filiptepper committed May 23, 2012
Showing with 1 addition and 10 deletions.
  1. +1 −7 go/src/mogrify/mogrify.go
  2. +0 −3 go/src/thumbnails/server.go
@@ -16,11 +16,7 @@ func init() {
}
func Resize(out io.Writer, in io.Reader, size string) (err error) {
- defer func() {
- log.Printf("resizing stream to %s - %t", size, err == nil)
- }()
-
- cmd := exec.Command("gm", "convert", "-resize", size, "-colorspace", "RGB", "-", "-")
+ cmd := exec.Command("gm", "convert", "-size", size, "-resize", size, "-", "-")
stdin, err := cmd.StdinPipe()
if err != nil {
return
@@ -37,8 +33,6 @@ func Resize(out io.Writer, in io.Reader, size string) (err error) {
return
}
- // copy stream ot gm tool, close stream once done and
- // read the output of the tool back to the out stream
io.Copy(stdin, in)
stdin.Close()
io.Copy(out, stdout)
@@ -6,7 +6,6 @@ import (
"flag"
"io"
"bytes"
- "strconv"
"os"
)
@@ -20,8 +19,6 @@ func main() {
buffer := bytes.NewBuffer(nil)
mogrify.Resize(buffer, content, "100x100")
- w.Header().Set("Content-Type", "image/jpeg")
- w.Header().Set("Content-Length", strconv.Itoa(buffer.Len()))
io.Copy(w, buffer)
return

0 comments on commit 31407c7

Please sign in to comment.