Skip to content

Instantly share code, notes, and snippets.

@fsouza
Created June 15, 2011 03:44
Show Gist options
  • Save fsouza/1026431 to your computer and use it in GitHub Desktop.
Save fsouza/1026431 to your computer and use it in GitHub Desktop.
package main
import (
"flag"
"fmt"
"image/png"
"os"
)
func main() {
flag.Parse()
inputFilename := flag.Arg(0)
outputFilename := flag.Arg(1)
if file, err := os.Open(inputFilename); err == nil {
defer file.Close()
image, _ := png.Decode(file)
if out, err := os.OpenFile(outputFilename, os.O_WRONLY|os.O_CREATE, 0644); err == nil {
defer out.Close()
png.Encode(out, image)
}
}
fmt.Println("I guess I saved the file", outputFilename)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment