qrcode icon indicating copy to clipboard operation
qrcode copied to clipboard

Usage examples

Open pbhogale opened this issue 4 years ago • 1 comments

Hi ! This looks like a very useful package but it is not at all clear how to use it to actually create QR codes as part of another haskell project.

would be great to have some code snippets and "hello world" examples.

pbhogale avatar Sep 02 '20 13:09 pbhogale

The most basic usage is the following:

import           Codec.Picture
import           Codec.QRCode
import           Codec.QRCode.JuicyPixels

main :: IO ()
main = do
  case encode (defaultQRCodeOptions M) Iso8859_1OrUtf8WithoutECI "Hello World: 1234 // ¢Aぴ¥" of
    Just qrcode -> savePngImage "/tmp/test.png" (ImageY8 $ toImage 0 1 qrcode)
    Nothing -> fail "error encoding the qrcode"

I hope that helps as a starting point.

alexkazik avatar Sep 02 '20 19:09 alexkazik