// The jpeg command reads a PNG image from the standard input// and writes it as a JPEG image to the standard output.packagemainimport("fmt""image""image/jpeg"_"image/png"// register PNG decoder"io""os")funcmain(){iferr:=toJPEG(os.Stdin,os.Stdout);err!=nil{fmt.Fprintf(os.Stderr,"jpeg: %v\n",err)os.Exit(1)}}functoJPEG(inio.Reader,outio.Writer)error{img,kind,err:=image.Decode(in)iferr!=nil{returnerr}fmt.Fprintln(os.Stderr,"Input format =",kind)returnjpeg.Encode(out,img,&jpeg.Options{Quality:95})}