added image in qr-code or next to name - improvements

This commit is contained in:
Marc Wäckerlin
2025-11-08 17:30:48 +01:00
parent 9c4d85528a
commit 0f802a02a8
10 changed files with 120 additions and 14 deletions
+58
View File
@@ -0,0 +1,58 @@
# LaTeX auxiliary files
*.aux
*.log
*.out
*.toc
*.synctex.gz
*.fdb_latexmk
*.fls
*.xdv
*.nav
*.snm
*.vrb
# Build directories
.texpadtmp/
*.d/
# Generated PDFs (comment out if you want to track them)
# *.pdf
# Autotools
/autom4te.cache/
/aclocal.m4
/compile
/config.guess
/config.h.in
/config.sub
/configure
/depcomp
/install-sh
/ltmain.sh
/missing
/texmf-dist/
*.tar.gz
*.tar.bz2
*.tar.xz
# Autoconf generated files
/config.status
/config.log
Makefile
makefile
makefile.in
/examples/makefile
/examples/makefile.in
/screenshots/makefile
/screenshots/makefile.in
# Backup files
*~
*.bak
*.swp
*.swo
\#*\#
# OS specific
.DS_Store
Thumbs.db
+10 -9
View File
@@ -94,10 +94,10 @@ Layout options are set as options to the `\documentclass`, e.g.:
- `fill` or `nofill`: fill empty space between icon and text, default: `fill`
- `qrfirst` or `textfirst`: switch position of QR-Code and text block, default: `qrfirst`
- `https` or `www`: should links in the hints be prefixed with `https://` or `www.`, default: `https`
- `qreclevel=`: QR error correction level `L`, `M`, `Q`, or `H`, default: `Q`. Increase to `H` if you use `photoinqr=true` or expect minor print noise.
- `photoinqr` or `nophotoinqr`: place photo in the center of the QR code (`photoinqr`) instead of next to the name, default: `nophotoinqr`. **Requires `qreclevel=H` for reliable scanning**, as the photo occludes part of the QR code (~15% by default).
- `qrlogoscale=`: relative size of the photo overlay in QR code (when `photoinqr=true`), as fraction of QR code width, default: `0.15` (15%). Higher values may reduce scannability.
- `qrlogoborder=`: white padding around the photo overlay (when `photoinqr=true`), as fraction of QR code width, default: `0.02` (2%). Increases contrast and readability for scanners.
- `qreclevel=`: QR error correction level `L` (~7%), `M` (~15%), `Q` (~25%), or `H` (~30%), default: `Q`. Use `H` when `photoinqr=true`.
- `photoinqr` or `nophotoinqr`: place photo in the center of the QR code (`photoinqr`) instead of next to the name, default: `nophotoinqr`. **Requires `qreclevel=H` for reliable scanning**.
- `qrlogoscale=`: photo size in QR code as percentage of QR width (0-100), default: `25` (25% width = 6.25% area). Recommended values: Level H: 25-30%, Level Q: 20%, Level M: 15%, Level L: 10%. Higher values may reduce scannability.
- `qrlogoborder=`: transparent padding around photo in QR code as percentage of QR width (0-100), default: `2` (2%). Adds space between photo and QR modules.
Data Definitions
@@ -204,7 +204,7 @@ See [examples] for more examples.
Photo (optional)
================
You can add an optional photo that appears next to the name or in the center of the QR code. The photo is dynamically scaled to match the name line height (when next to name) or to 15% of the QR code size (when in QR).
You can add an optional photo that appears next to the name or in the center of the QR code. The photo is dynamically scaled to match the name line height (when next to name) or to 25% of the QR code width (when in QR).
```latex
\photo{path/to/photo.jpg}
@@ -220,15 +220,16 @@ You can add an optional photo that appears next to the name or in the center of
**Photo in QR code center:**
```latex
\documentclass[photoinqr,qreclevel=H]{businesscard-qrcode}
\documentclass[photoinqr,qreclevel=H,qrlogoscale=25]{businesscard-qrcode}
\photo{photo.jpg}
```
**Important:** When using `photoinqr=true`:
- Always use `qreclevel=H` (highest error correction) for reliable scanning
- Always use `qreclevel=H` (highest error correction ~30%) for reliable scanning
- Test QR code scannability with multiple apps before printing
- Start with `qrlogoscale=0.15` and `qrlogoborder=0.02`; if scanning fails, try `qrlogoscale=0.12` or `0.10`
- The photo is placed on a white rounded rectangle background to preserve contrast
- Default `qrlogoscale=25` (25% width = 6.25% area) is recommended for Level H
- If scanning fails, reduce to `qrlogoscale=20` or `qrlogoscale=15`
- PNG transparency is preserved - use images with transparent backgrounds for best results
Need More
+6 -5
View File
@@ -21,8 +21,8 @@
\DeclareStringOption[0.50]{textwidth}
\DeclareStringOption[0.40]{qrwidth}
\DeclareStringOption[Q]{qreclevel} % QR code error correction level (L,M,Q,H) default Q
\DeclareStringOption[0.15]{qrlogoscale} % relative size of logo in QR code (0-1), default 0.15 = 15%
\DeclareStringOption[0.02]{qrlogoborder} % white padding around the photo overlay in QR code
\DeclareStringOption[25]{qrlogoscale} % photo size in QR code as percentage of QR width (0-100), default 25%
\DeclareStringOption[2]{qrlogoborder} % white padding around photo in QR as percentage of QR width (0-100), default 2%
\DeclareStringOption[de]{lang}
\DeclareBoolOption[false]{ioscrlf} % use CRLF line endings in vCard (iOS compatibility); default off to avoid pdfTeX issues
\DeclareBoolOption[false]{photoinqr} % if true: photo goes in QR center; if false (default): photo next to name
@@ -256,9 +256,10 @@ END:VCARD\BCQ@nl}
\ifcsdef{Xphoto}{%
\begin{tikzpicture}
\node[inner sep=0pt] (qr) {\qrcode[level=\BCQ@qreclevel,version=0,height=\textwidth]{\vcard}};
% White padding behind the photo to improve readability
\node[fill=white, rounded corners=0.5pt, inner sep=\BCQ@qrlogoborder\textwidth] at (qr.center) {%
\includegraphics[width=\BCQ@qrlogoscale\textwidth]{\Xphoto}%
% Photo with transparent background preserved (no fill), padding still applied
% Convert percentage values to fractions for calculations
\node[inner sep=\fpeval{\BCQ@qrlogoborder/100}\textwidth] at (qr.center) {%
\includegraphics[width=\fpeval{\BCQ@qrlogoscale/100}\textwidth]{\Xphoto}%
};
\end{tikzpicture}%
}{%
Binary file not shown.
+27
View File
@@ -0,0 +1,27 @@
% Example 1: Photo next to name (default)
\documentclass[qreclevel=Q]{businesscard-qrcode}
% Demonstrates optional photo placement:
% - Default: photo appears next to name (auto-scaled to name height)
% - Alternative: use photoinqr option to place photo in QR code center (requires qreclevel=H)
\photo{photo.png}
% Try alternative placement by uncommenting these lines and commenting out the \documentclass above:
% \documentclass[photoinqr,qreclevel=H,qrwidth=0.38,textwidth=0.57]{businesscard-qrcode}
\givennames{Alex}
\familynames{Muster}
\additionalnames{Example\ Company\ AG}
\type{work}
\phone{+41 44 123 45 67}
\email{alex.muster@example.com}
\homepage{example.com}
\github{example}
\gitea{git.example.org/example}
\city{Zürich}
\country{Switzerland}
\begin{document}
\drawcard
\end{document}
Binary file not shown.
+19
View File
@@ -0,0 +1,19 @@
% !TeX program = xelatex
\documentclass[photoinqr,qrlogoscale=40,qreclevel=H]{businesscard-qrcode}
\type{home}
\givennames{Lisa\ Linda}
\familynames{Doe}
\additionalnames{Example\ Company}
\street{Main\ Street\ 123}
\city{New\ York}
\zip{10001}
\country{USA}
\phone{+1 234 567 8900}
\email{ldoe@example.com}
\homepage{example.com}
\photo{photo.png}
\begin{document}
\drawcard
\end{document}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB