Saving QR to file for the second time gives different (corrupted) output
hubertat opened this issue · comments
When I create a QR code (doesn't matter is it with option, custom shape etc) and save it to file two (or more) times only 1st output is correct. Second (and third) output file is corrupted - few 'pixels' near finder areas are different.
Sample code:
plainQr, err := qrcode.New("https://github.com/")
if err != nil {
panic(err)
}
err = plainQr.Save("./out1.png")
if err != nil {
log.Println(err)
}
err = plainQr.Save("./out2.png")
if err != nil {
log.Println(err)
}
QR code out1.png
reads OK, out2.png
doesn't read at all.
You may ask why I'm saving same QR for the second time 😄 I'm doing custom multi colour codes and need to obtain width and height of the QR code - found this as solution: generate it for the first time to save maxH and maxW in my custom-shape object, then generate it for the second time to produce my coloured QR.
Let me check this issue
that's a bug, this library must support save QR Code image one more time and only generated once. By the way, do you need the size of QR code image? Should I support APIs to expose such attributes like width
, height
, padding
? @hubertat
In my implementation, I fill the matrix of QR Code, then I draw it into images, the size is determinate after drawing it. So I have no idea about how to expose those attributes before you called Save
and it-like functions yet.
Fixed it in #41, you can try it with branch issue-40/could-not-save-one-more-times
Yes! Already tried and using Attribute :) Thank you!
my pleasure 😉