Skip to content

Commit

Permalink
Merge pull request #46 from RexWzh/rex-dev
Browse files Browse the repository at this point in the history
update document
  • Loading branch information
RexWzh committed Nov 26, 2022
2 parents e2f3ae5 + 045356f commit 1b9b802
Show file tree
Hide file tree
Showing 8 changed files with 294 additions and 163 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -11,4 +11,5 @@ Manifest.toml

*.gif
*.png
*.jpg
*.jpg
*.svg
2 changes: 1 addition & 1 deletion Project.toml
@@ -1,7 +1,7 @@
name = "QRCoders"
uuid = "f42e9828-16f3-11ed-2883-9126170b272d"
authors = ["Jérémie Gillet <jie.gillet@gmail.com> and contributors"]
version = "1.4.0"
version = "1.4.1"

[deps]
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
Expand Down
36 changes: 29 additions & 7 deletions README.md
@@ -1,9 +1,8 @@
# QRCoders
![logo-QRCoders](https://cdn.jsdelivr.net/gh/juliaimages/QRCoders.jl@assets/logo-QRCoders.png)

[![][action-img]][action-url]
[![][pkgeval-img]][pkgeval-url]
[![][codecov-img]][codecov-url]
[![][docs-stable-img]][docs-stable-url]
[![][docs-dev-img]][docs-dev-url]

Create [QR Codes](https://en.wikipedia.org/wiki/QR_code) as data within Julia, or export as PNG.
Expand Down Expand Up @@ -41,10 +40,11 @@ A file will be saved at `./qrcode.png`.

> ![QRCode1](https://cdn.jsdelivr.net/gh/juliaimages/QRCoders.jl@assets/qrcode.png)
### QRCode struct
`QRCode` is a structure type that contains the data of a QR Code.
### QRCode type
`QRCode` is a structure type that contains the data of a QR Code. One can use
it as an input to call functions.

```jl
```julia
julia> code = QRCode("Hello world!")
█████████████████████████
██ ▄▄▄▄▄ █▀ █ ▄█ ▄▄▄▄▄ ██
Expand All @@ -59,10 +59,15 @@ julia> code = QRCode("Hello world!")
██ █▄▄▄█ █▀ █▄▀▀█▄█▄█▄██
██▄▄▄▄▄▄▄█▄█▄▄▄██▄█▄█▄███
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
julia> exportqrcode(code)
julia> qrcode(code) # get the data of the QR Code
julia> exportqrcode(code, "qrcode.png") # export to a file
julia> qrwidth(code) # get the width of the QR Code
```

Animated QR code is supported in version 1.3+.
The show method of `QRCode` is a visual representation of the QR Code using
unicode characters `['█', '▀', '▄', ' ']`.

Besides, animated QR code is supported in version 1.3+.

```jl
julia> exportqrcode(["Hello world!", "Hello Julia!"], fps=2)
Expand All @@ -72,6 +77,23 @@ julia> exportqrcode(["Hello world!", "Hello Julia!"], fps=2)
The keyword `fps` controls the frame rate of the animation.

### Styles of QRCode
> This part is still under development, see [issue#33](https://github.com/JuliaImages/QRCoders.jl/issues/33) for more information. Feel free to contribute or propose more ideas!
Plot an image inside a QRCode.

```julia
using TestImages, ColorTypes, ImageTransformations
using QRCoders
oriimg = testimage("cameraman")
code = QRCode("Hello world!", version=16, width=4)
img = imresize(oriimg, 66, 66) .|> Gray .|> round .|> Bool .|> !
imageinqrcode(code, img; rate=0.9) |> exportbitmat("qrcode-camera.png")
```
> ![cameraman](https://cdn.jsdelivr.net/gh/juliaimages/QRCoders.jl@assets/qrcode-camera.png)
Here `rate` is the damage rate of error correction codewords, it should be no greater than 1.

### Parameters

There are some optional arguments.
Expand Down
60 changes: 46 additions & 14 deletions docs/src/index.md
Expand Up @@ -10,15 +10,6 @@ exportqrcode
QRCode
```

## styled QR codes

Plot in REPL.

```@docs
unicodeplot
unicodeplotbychar
```

## Encoding modes
There are five several encoding mode currently supported.

Expand All @@ -42,9 +33,31 @@ Quartile
High
```

## Reed Solomon code

```@docs
Poly
generator_matrix
geterrcode
```
## styled QR codes

Plot in REPL.

```@docs
unicodeplot
unicodeplotbychar
```

Plot image in a QR code.

```@docs
imageinqrcode
```

# Examples

Create a QR code matrix.
## Create a QR code matrix

```julia
julia> using QRCoders
Expand All @@ -60,8 +73,8 @@ julia> qrcode("Hello world!")
1 1 1 1 1 1 1 0 1 0 1 1 0 1 1 1 0 0 1 0 0
```

Export a QR code image from message.

## Export to a file
### PNG file -- default
```julia
julia> exportqrcode("Hello world!")
```
Expand All @@ -70,15 +83,34 @@ A file will be saved at `./qrcode.png`.

> ![QRCode1](https://cdn.jsdelivr.net/gh/juliaimages/QRCoders.jl@assets/qrcode.png)
### GIF file
Create a `.gif` file from messages.

Use `.gif` file to show QR codes with different masks.
```julia
julia> # QR codes with different masks
julia> using QRCoders: penalty
julia> codes = [QRCode("Hello world!", mask = i) for i in 0:7]
julia> qrcode.(codes) .|> penalty |> print
[425, 485, 342, 318, 495, 562, 368, 415]
julia> exportqrcode(codes, fps=3)
```

> ![QRCode-masks](https://cdn.jsdelivr.net/gh/juliaimages/QRCoders.jl/docs/src/assets/qrcode-masks.gif)
> ![QRCode-masks](https://cdn.jsdelivr.net/gh/juliaimages/QRCoders.jl/docs/src/assets/qrcode-masks.gif)
## Styled QR codes
> This part is still under development, see [issue#33](https://github.com/JuliaImages/QRCoders.jl/issues/33) for more information. Feel free to contribute or propose more ideas!

Plot an image inside a QRCode.

```julia
using TestImages, ColorTypes, ImageTransformations
using QRCoders
oriimg = testimage("cameraman")
code = QRCode("Hello world!", version=16, width=4)
img = imresize(oriimg, 66, 66) .|> Gray .|> round .|> Bool .|> !
imageinqrcode(code, img; rate=0.9) |> exportbitmat("qrcode-camera.png")
```
> ![cameraman](https://cdn.jsdelivr.net/gh/juliaimages/QRCoders.jl@assets/qrcode-camera.png)
Here `rate` is the damage rate of error correction codewords, it should be no greater than 1.
3 changes: 2 additions & 1 deletion src/QRCoders.jl
Expand Up @@ -25,7 +25,8 @@ export
EncodeError,
# QR code style
unicodeplot, unicodeplotbychar,
imageinqrcode, getfreeinfo, getimagescore
imageinqrcode, getfreeinfo, getimagescore,
validaligment, fitimgwidth

# Data types in QRCoders
include("types.jl")
Expand Down

2 comments on commit 1b9b802

@RexWzh
Copy link
Member Author

@RexWzh RexWzh commented on 1b9b802 Nov 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/72925

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.4.1 -m "<description of version>" 1b9b8021c498efd0d5ab519165e1c29144943d5d
git push origin v1.4.1

Please sign in to comment.