rename photo to logo

This commit is contained in:
Marc Wäckerlin
2025-11-09 11:17:49 +01:00
parent 07898c33a1
commit eb1e9451e9
12 changed files with 63 additions and 63 deletions
+20 -20
View File
@@ -95,11 +95,11 @@ Layout options are set as options to the `\documentclass`, e.g.:
- `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`
- `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 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.
- `qreclevel=`: QR error correction level `L` (~7%), `M` (~15%), `Q` (~25%), or `H` (~30%), default: `Q`. Use `H` when `logoinqr=true`.
- `logoinqr` or `nologoinqr`: place logo in the center of the QR code (`logoinqr`) instead of next to the name, default: `nologoinqr`. **Requires `qreclevel=H` for reliable scanning**.
- `qrlogoscale=`: logo 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 logo in QR code as fraction of QR width (1.0 = 100%), default: `0.02` (2%). Adds space between logo and QR modules.
- `logoscale=`: scale factor for logo next to name (1.0 = 100% of name height), default: `1.0`. Use values like `2.0` or `2.5` for larger logos.
- `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.
@@ -160,7 +160,7 @@ 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)
- `\logo`: path to logo file (PNG, JPG, etc.) for display next to name or in QR code (if `logoinqr` 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.
@@ -208,40 +208,40 @@ Save it as file [texstudio_d30266.tex] and compile it to get [texstudio_d30266.p
See [examples] for more examples.
Photo (optional)
================
Logo (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 25% of the QR code width (when in QR).
You can add an optional logo that appears next to the name or in the center of the QR code. The logo 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.png}
\logo{path/to/logo.png}
```
### Photo Placement Options:
### Logo Placement Options:
**Default (photo next to name):**
**Default (logo next to name):**
```latex
\documentclass{businesscard-qrcode}
\photo{photo.png}
\logo{logo.png}
```
**Photo in QR code center:**
**Logo in QR code center:**
```latex
\documentclass[photoinqr,qreclevel=H,qrlogoscale=0.25]{businesscard-qrcode}
\photo{photo.png}
\documentclass[logoinqr,qreclevel=H,qrlogoscale=0.25]{businesscard-qrcode}
\logo{logo.png}
```
**Important:** When using `photoinqr=true`:
**Important:** When using `logoinqr=true`:
- Always use `qreclevel=H` (highest error correction ~30%) for reliable scanning
- Test QR code scannability with multiple apps before printing
- 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:**
**Large logo next to name:**
```latex
\documentclass[photoscale=2.5]{businesscard-qrcode}
\photo{photo.png}
\documentclass[logoscale=2.5]{businesscard-qrcode}
\logo{logo.png}
```
**Background color:**
+21 -21
View File
@@ -21,15 +21,15 @@
\DeclareStringOption[0.50]{textwidth}
\DeclareStringOption[0.40]{qrwidth}
\DeclareStringOption[Q]{qreclevel} % QR code error correction level (L,M,Q,H) default Q
\DeclareStringOption[0.25]{qrlogoscale} % photo size in QR code as fraction of QR width (1.0 = 100%), default 0.25
\DeclareStringOption[0.02]{qrlogoborder} % white padding around photo in QR as fraction of QR width (1.0 = 100%), default 0.02
\DeclareStringOption[1.0]{photoscale} % scale factor for photo next to name (1.0 = 100% name height), default 1.0
\DeclareStringOption[0.25]{qrlogoscale} % logo size in QR code as fraction of QR width (1.0 = 100%), default 0.25
\DeclareStringOption[0.02]{qrlogoborder} % white padding around logo in QR as fraction of QR width (1.0 = 100%), default 0.02
\DeclareStringOption[1.0]{logoscale} % scale factor for logo next to name (1.0 = 100% name height), default 1.0
\DeclareStringOption[1.0]{bgscale} % background image scale (1.0 = 100% card height), default 1.0
\DeclareStringOption[1.0]{bgopacity} % background image opacity (1.0 = 100% visible, 0.0 = invisible), default 1.0
\DeclareStringOption[1.0]{qrbgopacity} % QR code background opacity (1.0 = white solid, 0.0 = transparent), default 1.0
\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
\DeclareBoolOption[false]{logoinqr} % if true: logo goes in QR center; if false (default): logo next to name
\DeclareBoolOption[true]{address}
\DeclareComplementaryOption{noaddress}{address}
\DeclareBoolOption[true]{hint}
@@ -77,7 +77,7 @@
\RequirePackage{DejaVuSans}
\RequirePackage[T1]{fontenc}
\RequirePackage{wrapfig}
\RequirePackage{graphicx} % needed for optional photo
\RequirePackage{graphicx} % needed for optional logo
\RequirePackage{tikz} % needed for logo overlay in QR code
\RequirePackage{eso-pic} % needed for background images without layout impact
% Fix XeLaTeX opacity issue: ensure TikZ/PGF is loaded before eso-pic uses opacity
@@ -133,7 +133,7 @@
\registerData{google}
\registerData{pgpurl}
\registerData{pgpfingerprint}
\registerData{photo} % path to photo file for display next to name
\registerData{logo} % path to logo file for display next to name
\registerData{background} % path to background image file or color name
@@ -159,7 +159,7 @@
% name - assemble full name from the parts, such as Xgivennames and Xfamilynames
\newcommand\name{\ifexists{Xhonoricprefix}{\Xhonoricprefix\ }\ifexists{Xgivennames}{\Xgivennames\ }\ifexists{Xfamilynames}{\Xfamilynames}\ifexists{Xhonoricsuffix}{\ \Xhonoricsuffix}}
% internal box for measuring name height when photo is present
% internal box for measuring name height when logo is present
\newsavebox{\BCQ@namebox}
@@ -297,19 +297,19 @@ END:VCARD\BCQ@nl}
\node[fill=white, opacity=\fpeval{\BCQ@qrbgopacity}, inner sep=0pt, outer sep=2mm, minimum size=\textwidth] (bg) at (0,0) {};
% QR code on top
\node[inner sep=0pt, outer sep=0pt] (qr) at (0,0) {%
\ifBCQ@photoinqr
% QR code with photo overlay in center
\ifcsdef{Xphoto}{%
\ifBCQ@logoinqr
% QR code with logo overlay in center
\ifcsdef{Xlogo}{%
\begin{tikzpicture}
\node[inner sep=0pt] (qr2) {\qrcode[level=\BCQ@qreclevel,version=0,height=\textwidth]{\vcard}};
% Photo with transparent background preserved (no fill), padding still applied
% Logo with transparent background preserved (no fill), padding still applied
% qrlogoscale and qrlogoborder are now fractions (1.0 = 100%)
\node[inner sep=\BCQ@qrlogoborder\textwidth] at (qr2.center) {%
\includegraphics[width=\BCQ@qrlogoscale\textwidth]{\Xphoto}%
\includegraphics[width=\BCQ@qrlogoscale\textwidth]{\Xlogo}%
};
\end{tikzpicture}%
}{%
% No photo defined, just show QR code
% No logo defined, just show QR code
\qrcode[level=\BCQ@qreclevel,version=0,height=\textwidth]{\vcard}%
}%
\else
@@ -328,16 +328,16 @@ END:VCARD\BCQ@nl}
\newcommand\insertname{
% typeset name into box for measurement
\sbox{\BCQ@namebox}{\bfseries\cond{name}\ifexists{Xadditionalnames}{\ifcsempty{name}{} { }\Xadditionalnames}}%
\ifcsdef{Xphoto}{% photo defined
\ifBCQ@photoinqr
% Photo in QR code: show name only, same structure as no-photo case
\ifcsdef{Xlogo}{% logo defined
\ifBCQ@logoinqr
% Logo in QR code: show name only, same structure as no-logo case
{\bfseries\usebox{\BCQ@namebox}}%
\else
% Photo next to name: two-column layout (photo | name)
% photoscale: 1.0 = 100% name height (default), 2.0 = 200%, etc.
% Logo next to name: two-column layout (logo | name)
% logoscale: 1.0 = 100% name height (default), 2.0 = 200%, etc.
\begin{minipage}{\textwidth}
\begin{minipage}[c]{0.30\textwidth}% photo column (increased from 0.22)
\includegraphics[height=\fpeval{\BCQ@photoscale}\dimexpr\ht\BCQ@namebox+\dp\BCQ@namebox\relax]{\Xphoto}% scaled to photoscale * name height
\begin{minipage}[c]{0.30\textwidth}% logo column (increased from 0.22)
\includegraphics[height=\fpeval{\BCQ@logoscale}\dimexpr\ht\BCQ@namebox+\dp\BCQ@namebox\relax]{\Xlogo}% scaled to logoscale * name height
\end{minipage}
\hfill
\begin{minipage}[c]{0.67\textwidth}% name column (adjusted from 0.75)
@@ -346,7 +346,7 @@ END:VCARD\BCQ@nl}
\end{minipage}
\end{minipage}
\fi
}{% no photo: just name
}{% no logo: just name
{\bfseries\usebox{\BCQ@namebox}}%
}
}
Binary file not shown.
+2 -2
View File
@@ -1,5 +1,5 @@
% !TeX program = xelatex
\documentclass[bgscale=1.2,bgopacity=0.6,qrbgopacity=0.8,photoscale=4]{businesscard-qrcode}
\documentclass[bgscale=1.2,bgopacity=0.6,qrbgopacity=0.8,logoscale=4]{businesscard-qrcode}
\type{home}
\givennames{Petra}
@@ -12,7 +12,7 @@
\phone{+41 61 123 45 67}
\email{petra@example.ch}
\background{background.png}
\photo{photo.png}
\logo{photo.png}
\begin{document}
\drawcard
Binary file not shown.
+6 -6
View File
@@ -1,14 +1,14 @@
% Example 1: Photo next to name (default)
% Example 1: Logo 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)
% Demonstrates optional logo placement:
% - Default: logo appears next to name (auto-scaled to name height)
% - Alternative: use logoinqr option to place logo in QR code center (requires qreclevel=H)
\photo{photo.png}
\logo{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}
% \documentclass[logoinqr,qreclevel=H,qrwidth=0.38,textwidth=0.57]{businesscard-qrcode}
\givennames{Alex}
\familynames{Muster}
Binary file not shown.
+2 -2
View File
@@ -1,5 +1,5 @@
% !TeX program = xelatex
\documentclass[photoinqr,qrlogoscale=0.4,qreclevel=H]{businesscard-qrcode}
\documentclass[logoinqr,qrlogoscale=0.4,qreclevel=H]{businesscard-qrcode}
\type{home}
\givennames{Lisa\ Linda}
@@ -12,7 +12,7 @@
\phone{+1 234 567 8900}
\email{ldoe@example.com}
\homepage{example.com}
%\photo{photo.png} % uncomment if photo.png exists
%\logo{photo.png} % uncomment if photo.png exists
\begin{document}
\drawcard
Binary file not shown.
+3 -3
View File
@@ -1,16 +1,16 @@
\documentclass[bgscale=1.2,bgopacity=0.6,qrbgopacity=0.8,photoscale=4]{businesscard-qrcode}
\documentclass[bgscale=1.2,bgopacity=0.6,qrbgopacity=0.8,logoscale=4]{businesscard-qrcode}
\type{home}
\givennames{Max}
\familynames{Muster}
\additionalnames{Big\ Photo\ Example}
\additionalnames{Big\ Logo\ Example}
\street{Beispielstrasse\ 42}
\city{Winterthur}
\zip{8400}
\country{CH}
\phone{+41 52 123 45 67}
\email{max@example.ch}
\photo{photo.png}
\logo{photo.png}
\background{background.png}
\begin{document}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB