A Clojure library designed to encode and decode QR codes using the zxing library.
Available on clojars.
[com.nopolabs/clozxing "0.1.1"]
(encode/to-image text)
(encode/to-image text opts)
Encodes text to a QR code. Returns a java.awt.image.BufferedImage.
(encode/to-stream text stream)
(encode/to-stream stream opts)
Encodes text to a QR code and writes results to provided java.io.OutpuStream. Returns true if successful.
Default output format is PNG, format can be specified in opts, e.g.: { :format "JPG" }.
(encode/to-file text file)
(encode/to-file file opts)
Encodes text to a QR code and writes results to provided file. Returns true if successful.
The file parameter may either be a String or a java.io.File.
Output format is determined from file name suffix and can be overridden in opts, e.g.: { :format "JPG" }.
The size of the desired QR code in pixels (a size x size square).
Margin (in pixels) around generated QR code.
Output image format (JPEG, PNG, GIF, BMP or WBMP)
This is a hint for the desired logo size. Logo overlays are possible because of QR code error correction. Encoder will try overlaying progressively smaller logos in the center of the QR code image until it finds a combination that can be successfully decoded.
Defaults are defined in encode/default-opts
There are no defaults for :logo
and :logo-size
(def default-opts
{:size 300
:error-correction error-correction-H
:character-set iso-8859-1
:margin 1
:format "PNG"})
(encode/to-file
"https://github.com/nopolabs/clozxing"
"clozxing.png"
{ :size 200
:logo "dev-resources/logo.png"
:logo-size 67
:error-correction encode/error-correction-H
:character-set encode/iso-8859-1
:margin 1
:format "PNG" }))
(decode/from-stream stream)
Reads and decodes QR code from provided java.io.InputStream. Returns decoded text if successful.
(decode/from-file file)
Reads and decodes QR code from file. Returns decoded text if successful.
The file parameter may either be a String or a java.io.File.
(decode/from-bytes bytes)
Reads and decodes QR code from provided byte array. Returns decoded text if successful.
(decode/from-image image)
Reads and decodes QR code from provided java.awt.image.BufferedImage. Returns decoded text if successful.
(decode/from-url url)
Reads and decodes QR code from provided java.net.URL. Returns decoded text if successful.
(decode/file "clozxing.png")
Copyright © 2020 nopolabs
This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version, with the GNU Classpath Exception which is available at https://www.gnu.org/software/classpath/license.html.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close