Created
June 15, 2011 03:44
-
-
Save fsouza/1026431 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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