WriteFile writes the QR Code as a PNG image to the specified file. size is both the image width and height in pixels. If size is too small then a larger image is silently written. Negative values for size cause a variable sized image to be written: See the documentation for Image().
(size int, filename string)
| 374 | // a larger image is silently written. Negative values for size cause a |
| 375 | // variable sized image to be written: See the documentation for Image(). |
| 376 | func (q *QRCode) WriteFile(size int, filename string) error { |
| 377 | var png []byte |
| 378 | |
| 379 | png, err := q.PNG(size) |
| 380 | |
| 381 | if err != nil { |
| 382 | return err |
| 383 | } |
| 384 | |
| 385 | return ioutil.WriteFile(filename, png, os.FileMode(0644)) |
| 386 | } |
| 387 | |
| 388 | // encode completes the steps required to encode the QR Code. These include |
| 389 | // adding the terminator bits and padding, splitting the data into blocks and |