added background with opacity to QR-Code and card; bug in card opacity

This commit is contained in:
Marc Wäckerlin
2025-11-09 09:08:09 +01:00
parent 407c7eed2d
commit 2c2fbdbe9e
13 changed files with 150 additions and 32 deletions
+30 -5
View File
@@ -97,8 +97,12 @@ Layout options are set as options to the `\documentclass`, e.g.:
- `countryformat=`: how to format the country in address. Values: `auto` (default: inline with mdash if <4 chars and city/zip exists), `inline` (always inline with mdash), `below` (always separate line)
- `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.
- `qrlogoscale=`: photo size in QR code as fraction of QR width (1.0 = 100%), default: `0.25` (25% width). Recommended values: Level H: 0.25-0.3, Level Q: 0.2, Level M: 0.15, Level L: 0.1. Higher values may reduce scannability.
- `qrlogoborder=`: transparent padding around photo in QR code as fraction of QR width (1.0 = 100%), default: `0.02` (2%). Adds space between photo and QR modules.
- `photoscale=`: scale factor for photo next to name (1.0 = 100% of name height), default: `1.0`. Use values like `2.0` or `2.5` for larger photos.
- `bgscale=`: background image scale factor (1.0 = 100% of card height), default: `1.0`. Use values like `1.5` or `2.0` for zoomed/cropped backgrounds. Only affects images, not colors.
- `bgopacity=`: background image opacity/transparency (1.0 = 100% visible, 0.0 = invisible), default: `1.0`. Use lower values like `0.2` or `0.3` to fade the background so text remains readable. Only affects images, not colors.
- `qrbgopacity=`: QR code background opacity (1.0 = solid white, 0.0 = transparent), default: `1.0`. White background behind QR code ensures scannability over background images. Use `0.0` for no background or lower values like `0.8` for semi-transparent.
Data Definitions
@@ -156,6 +160,8 @@ See this example_
- `\google`: your account name on [google+] — only the name of the account, the url is prepended automatically
- `\pgpurl`: the full url to your pgp public key (only added to the QR-Code, not shown in the text)
- `\pgpfingerprint`: the fingerprint of your pgp public key
- `\photo`: path to photo file (PNG, JPG, etc.) for display next to name or in QR code (if `photoinqr` option is set)
- `\background`: path to background image file or color name (e.g., `yellow!20`, `blue!10`). If file exists, it's used as image; otherwise treated as color.
Print the Card
@@ -221,17 +227,36 @@ 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,qrlogoscale=25]{businesscard-qrcode}
\documentclass[photoinqr,qreclevel=H,qrlogoscale=0.25]{businesscard-qrcode}
\photo{photo.jpg}
```
**Important:** When using `photoinqr=true`:
- Always use `qreclevel=H` (highest error correction ~30%) for reliable scanning
- Test QR code scannability with multiple apps before printing
- Default `qrlogoscale=25` (25% width = 6.25% area) is recommended for Level H
- If scanning fails, reduce to `qrlogoscale=20` or `qrlogoscale=15`
- Default `qrlogoscale=0.25` (25% width = 6.25% area) is recommended for Level H
- If scanning fails, reduce to `qrlogoscale=0.2` or `qrlogoscale=0.15`
- PNG transparency is preserved - use images with transparent backgrounds for best results
**Large photo next to name:**
```latex
\documentclass[photoscale=2.5]{businesscard-qrcode}
\photo{photo.jpg}
```
**Background color:**
```latex
\documentclass{businesscard-qrcode}
\background{yellow!20}
```
**Background image:**
```latex
\documentclass[bgscale=1.5,bgopacity=0.3,qrbgopacity=1.0]{businesscard-qrcode}
\background{photo.jpg}
```
Note: Use `bgopacity` to fade the background (e.g., `0.2` or `0.3`) so text remains readable. The QR code has a white background by default (`qrbgopacity=1.0`) to ensure scannability.
Need More
=========