Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ on:
push:
branches:
- master
tags: '*'
tags:
- '*'
pull_request:
concurrency:
# Skip intermediate builds: always.
Expand Down Expand Up @@ -35,7 +36,7 @@ jobs:
version: '1'
arch: x86
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
Expand All @@ -44,6 +45,6 @@ jobs:
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v2
- uses: codecov/codecov-action@v4
with:
files: lcov.info
7 changes: 4 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ on:
branches:
- 'master'
- 'release-'
tags: '*'
tags:
- '*'
release:
types: [published]

Expand All @@ -18,12 +19,12 @@ jobs:
julia-version: [1]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.julia-version }}
- name: Cache artifacts
uses: actions/cache@v1
uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
Expand Down
16 changes: 10 additions & 6 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
name = "QRCoders"
uuid = "f42e9828-16f3-11ed-2883-9126170b272d"
authors = ["Jérémie Gillet <jie.gillet@gmail.com> and contributors"]
version = "1.4.5"
version = "1.4.6"

[deps]
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19"
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
ImageTransformations = "02fcd773-0e25-5acc-982a-7f6622650795"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228"

[compat]
ColorTypes = "0.11 - 0.12"
FileIO = "1"
ImageCore = "0.8, 0.9"
ImageIO = "0.4, 0.5, 0.6"
ImageCore = "0.8 - 0.10"
ImageIO = "0.4 - 0.6"
ImageMagick = "1"
StatsBase = "0.33"
UnicodePlots = "2.7 - 2.12"
julia = "1.3"
ImageTransformations = "0.9 - 0.10.2"
StatsBase = "0.33 - 0.34"
UnicodePlots = "3 - 3.8"
julia = "1.6"
70 changes: 64 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,35 @@ A file will be saved at `./qrcode.png`.

> ![QRCode1](https://cdn.jsdelivr.net/gh/juliaimages/QRCoders.jl@assets/qrcode.png)


### Export or Display as SVG

You can generate a QR code as an SVG string, control its size and colors, and write it to a file.

#### Simple usage

```julia
julia> using QRCoders

julia> svgstr = exportsvg("Hello!"); # Black on white SVG string

julia> tmp = mktempdir();

julia> file_path = joinpath(tmp, "hello.svg")

julia> exportsvg("Another code"; path=file_path) # Writes SVG file
```

#### Custom colors

You can set module/background CSS colors:

```julia
julia> s = exportsvg("Color Demo"; darkcolor="navy", lightcolor="#ffb");
```

You can then display the SVG in a browser, include it in an HTML page, or use it directly in web applications.

### 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.
Expand Down Expand Up @@ -83,13 +112,42 @@ The keyword `fps` controls the frame rate of the animation.
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")
julia> using TestImages, ColorTypes, ImageTransformations

julia> using QRCoders

julia> oriimg = testimage("cameraman")

julia> code = QRCode("Hello world!", version=16, width=4)

julia> img = imresize(oriimg, 66, 66) .|> Gray .|> round .|> Bool .|> !

julia> imageinqrcode(code, img; rate=0.9) |> exportbitmat("qrcode-camera.png")
```

For SGV do this:


#### Advanced: Render any Boolean matrix as SVG

To display a QR code or styled/custom QR overlays (e.g. using images), use `matrix2svg`:

```julia
julia> using TestImages, ColorTypes, ImageTransformations

julia> oriimg = testimage("cameraman")

julia> code = QRCode("Hello world!", version=16, width=4)

julia> img = imresize(oriimg, 66, 66) .|> Gray .|> round .|> Bool .|> !

julia> qrmat = imageinqrcode(code, img; rate=0.9)

julia> svgout = matrix2svg(qrmat; darkcolor="maroon", lightcolor="#faf9f1")

julia> open("myfancyqr.svg", "w") do f; write(f, svgout); end
```

> ![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.
Expand Down
77 changes: 68 additions & 9 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Module that can create QR codes as data or images using `qrcode` or `exportqrcod
```@docs
qrcode
exportqrcode
exportsvg
QRCode
```

Expand Down Expand Up @@ -53,6 +54,7 @@ Plot image in a QR code.

```@docs
imageinqrcode
matrix2svg
```

# Examples
Expand Down Expand Up @@ -97,20 +99,77 @@ julia> exportqrcode(codes, fps=3)

> ![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!

### Export or Display as SVG

You can generate a QR code as an SVG string, control its size and colors, and write it to a file.

#### Simple usage

```julia
julia> using QRCoders

julia> svgstr = exportsvg("Hello!"); # Black on white SVG string

julia> tmp = mktempdir();

julia> file_path = joinpath(tmp, "hello.svg")

julia> exportsvg("Another code"; path=file_path) # Writes SVG file
```

#### Custom colors

You can set module/background CSS colors:

```julia
julia> s = exportsvg("Color Demo"; darkcolor="navy", lightcolor="#ffb");
```

You can then display the SVG in a browser, include it in an HTML page, or use it directly in web applications.

### 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")
julia> using TestImages, ColorTypes, ImageTransformations

julia> using QRCoders

julia> oriimg = testimage("cameraman")

julia> code = QRCode("Hello world!", version=16, width=4)

julia> img = imresize(oriimg, 66, 66) .|> Gray .|> round .|> Bool .|> !

julia> imageinqrcode(code, img; rate=0.9) |> exportbitmat("qrcode-camera.png")
```

For SGV do this:


#### Advanced: Render any Boolean matrix as SVG

To display a QR code or styled/custom QR overlays (e.g. using images), use `matrix2svg`:

```julia
julia> using TestImages, ColorTypes, ImageTransformations

julia> oriimg = testimage("cameraman")

julia> code = QRCode("Hello world!", version=16, width=4)

julia> img = imresize(oriimg, 66, 66) .|> Gray .|> round .|> Bool .|> !

julia> qrmat = imageinqrcode(code, img; rate=0.9)

julia> svgout = matrix2svg(qrmat; darkcolor="maroon", lightcolor="#faf9f1")

julia> open("myfancyqr.svg", "w") do f; write(f, svgout); end
```

> ![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.
Here `rate` is the damage rate of error correction codewords, it should be no greater than 1.
5 changes: 2 additions & 3 deletions src/QRCoders.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ using ImageCore
using FileIO
using UnicodePlots
using StatsBase

export
# create QR code
qrcode, exportqrcode, QRCode,
exportbitmat, addborder,
exportbitmat, addborder,exportsvg,matrix2svg,
# supported modes
Mode, Numeric, Alphanumeric, Byte, Kanji, UTF8,
# error correction levels
Expand All @@ -25,7 +24,7 @@ export
# information about QR code
getmode, getversion, qrwidth, makemask,
qrversionbits, qrformat, encodemessage,

# locate QR matrix
validalignment, getversioninds,
getformatinds, gettiminginds, getsepinds,
Expand Down
Loading
Loading