Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage examples #2

Open
pbhogale opened this issue Sep 2, 2020 · 1 comment
Open

Usage examples #2

pbhogale opened this issue Sep 2, 2020 · 1 comment

Comments

@pbhogale
Copy link

pbhogale commented Sep 2, 2020

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.

@alexkazik
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants