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` - `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` - `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) - `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`. - `qreclevel=`: QR error correction level `L` (~7%), `M` (~15%), `Q` (~25%), or `H` (~30%), default: `Q`. Use `H` when `logoinqr=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**. - `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=`: 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. - `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 photo in QR code as fraction of QR width (1.0 = 100%), default: `0.02` (2%). Adds space between photo and QR modules. - `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.
- `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. - `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. - `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. - `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. - `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 - `\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) - `\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 - `\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. - `\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. 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 ```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 ```latex
\documentclass{businesscard-qrcode} \documentclass{businesscard-qrcode}
\photo{photo.png} \logo{logo.png}
``` ```
**Photo in QR code center:** **Logo in QR code center:**
```latex ```latex
\documentclass[photoinqr,qreclevel=H,qrlogoscale=0.25]{businesscard-qrcode} \documentclass[logoinqr,qreclevel=H,qrlogoscale=0.25]{businesscard-qrcode}
\photo{photo.png} \logo{logo.png}
``` ```
**Important:** When using `photoinqr=true`: **Important:** When using `logoinqr=true`:
- Always use `qreclevel=H` (highest error correction ~30%) for reliable scanning - Always use `qreclevel=H` (highest error correction ~30%) for reliable scanning
- Test QR code scannability with multiple apps before printing - Test QR code scannability with multiple apps before printing
- Default `qrlogoscale=0.25` (25% width = 6.25% area) is recommended for Level H - 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` - If scanning fails, reduce to `qrlogoscale=0.2` or `qrlogoscale=0.15`
- PNG transparency is preserved - use images with transparent backgrounds for best results - PNG transparency is preserved - use images with transparent backgrounds for best results
**Large photo next to name:** **Large logo next to name:**
```latex ```latex
\documentclass[photoscale=2.5]{businesscard-qrcode} \documentclass[logoscale=2.5]{businesscard-qrcode}
\photo{photo.png} \logo{logo.png}
``` ```
**Background color:** **Background color:**
+30 -30
View File
@@ -21,15 +21,15 @@
\DeclareStringOption[0.50]{textwidth} \DeclareStringOption[0.50]{textwidth}
\DeclareStringOption[0.40]{qrwidth} \DeclareStringOption[0.40]{qrwidth}
\DeclareStringOption[Q]{qreclevel} % QR code error correction level (L,M,Q,H) default Q \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.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 photo in QR as fraction of QR width (1.0 = 100%), default 0.02 \DeclareStringOption[0.02]{qrlogoborder} % white padding around logo 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[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]{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]{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[1.0]{qrbgopacity} % QR code background opacity (1.0 = white solid, 0.0 = transparent), default 1.0
\DeclareStringOption[de]{lang} \DeclareStringOption[de]{lang}
\DeclareBoolOption[false]{ioscrlf} % use CRLF line endings in vCard (iOS compatibility); default off to avoid pdfTeX issues \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} \DeclareBoolOption[true]{address}
\DeclareComplementaryOption{noaddress}{address} \DeclareComplementaryOption{noaddress}{address}
\DeclareBoolOption[true]{hint} \DeclareBoolOption[true]{hint}
@@ -77,7 +77,7 @@
\RequirePackage{DejaVuSans} \RequirePackage{DejaVuSans}
\RequirePackage[T1]{fontenc} \RequirePackage[T1]{fontenc}
\RequirePackage{wrapfig} \RequirePackage{wrapfig}
\RequirePackage{graphicx} % needed for optional photo \RequirePackage{graphicx} % needed for optional logo
\RequirePackage{tikz} % needed for logo overlay in QR code \RequirePackage{tikz} % needed for logo overlay in QR code
\RequirePackage{eso-pic} % needed for background images without layout impact \RequirePackage{eso-pic} % needed for background images without layout impact
% Fix XeLaTeX opacity issue: ensure TikZ/PGF is loaded before eso-pic uses opacity % Fix XeLaTeX opacity issue: ensure TikZ/PGF is loaded before eso-pic uses opacity
@@ -133,7 +133,7 @@
\registerData{google} \registerData{google}
\registerData{pgpurl} \registerData{pgpurl}
\registerData{pgpfingerprint} \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 \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 % 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}} \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} \newsavebox{\BCQ@namebox}
@@ -297,21 +297,21 @@ END:VCARD\BCQ@nl}
\node[fill=white, opacity=\fpeval{\BCQ@qrbgopacity}, inner sep=0pt, outer sep=2mm, minimum size=\textwidth] (bg) at (0,0) {}; \node[fill=white, opacity=\fpeval{\BCQ@qrbgopacity}, inner sep=0pt, outer sep=2mm, minimum size=\textwidth] (bg) at (0,0) {};
% QR code on top % QR code on top
\node[inner sep=0pt, outer sep=0pt] (qr) at (0,0) {% \node[inner sep=0pt, outer sep=0pt] (qr) at (0,0) {%
\ifBCQ@photoinqr \ifBCQ@logoinqr
% QR code with photo overlay in center % QR code with logo overlay in center
\ifcsdef{Xphoto}{% \ifcsdef{Xlogo}{%
\begin{tikzpicture} \begin{tikzpicture}
\node[inner sep=0pt] (qr2) {\qrcode[level=\BCQ@qreclevel,version=0,height=\textwidth]{\vcard}}; \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%) % qrlogoscale and qrlogoborder are now fractions (1.0 = 100%)
\node[inner sep=\BCQ@qrlogoborder\textwidth] at (qr2.center) {% \node[inner sep=\BCQ@qrlogoborder\textwidth] at (qr2.center) {%
\includegraphics[width=\BCQ@qrlogoscale\textwidth]{\Xphoto}% \includegraphics[width=\BCQ@qrlogoscale\textwidth]{\Xlogo}%
}; };
\end{tikzpicture}% \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}% \qrcode[level=\BCQ@qreclevel,version=0,height=\textwidth]{\vcard}%
}% }%
\else \else
% Standard QR code without overlay % Standard QR code without overlay
\qrcode[level=\BCQ@qreclevel,version=0,height=\textwidth]{\vcard}% \qrcode[level=\BCQ@qreclevel,version=0,height=\textwidth]{\vcard}%
@@ -328,16 +328,16 @@ END:VCARD\BCQ@nl}
\newcommand\insertname{ \newcommand\insertname{
% typeset name into box for measurement % typeset name into box for measurement
\sbox{\BCQ@namebox}{\bfseries\cond{name}\ifexists{Xadditionalnames}{\ifcsempty{name}{} { }\Xadditionalnames}}% \sbox{\BCQ@namebox}{\bfseries\cond{name}\ifexists{Xadditionalnames}{\ifcsempty{name}{} { }\Xadditionalnames}}%
\ifcsdef{Xphoto}{% photo defined \ifcsdef{Xlogo}{% logo defined
\ifBCQ@photoinqr \ifBCQ@logoinqr
% Photo in QR code: show name only, same structure as no-photo case % Logo in QR code: show name only, same structure as no-logo case
{\bfseries\usebox{\BCQ@namebox}}% {\bfseries\usebox{\BCQ@namebox}}%
\else \else
% Photo next to name: two-column layout (photo | name) % Logo next to name: two-column layout (logo | name)
% photoscale: 1.0 = 100% name height (default), 2.0 = 200%, etc. % logoscale: 1.0 = 100% name height (default), 2.0 = 200%, etc.
\begin{minipage}{\textwidth} \begin{minipage}{\textwidth}
\begin{minipage}[c]{0.30\textwidth}% photo column (increased from 0.22) \begin{minipage}[c]{0.30\textwidth}% logo column (increased from 0.22)
\includegraphics[height=\fpeval{\BCQ@photoscale}\dimexpr\ht\BCQ@namebox+\dp\BCQ@namebox\relax]{\Xphoto}% scaled to photoscale * name height \includegraphics[height=\fpeval{\BCQ@logoscale}\dimexpr\ht\BCQ@namebox+\dp\BCQ@namebox\relax]{\Xlogo}% scaled to logoscale * name height
\end{minipage} \end{minipage}
\hfill \hfill
\begin{minipage}[c]{0.67\textwidth}% name column (adjusted from 0.75) \begin{minipage}[c]{0.67\textwidth}% name column (adjusted from 0.75)
@@ -346,7 +346,7 @@ END:VCARD\BCQ@nl}
\end{minipage} \end{minipage}
\end{minipage} \end{minipage}
\fi \fi
}{% no photo: just name }{% no logo: just name
{\bfseries\usebox{\BCQ@namebox}}% {\bfseries\usebox{\BCQ@namebox}}%
} }
} }
Binary file not shown.
+2 -2
View File
@@ -1,5 +1,5 @@
% !TeX program = xelatex % !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} \type{home}
\givennames{Petra} \givennames{Petra}
@@ -12,7 +12,7 @@
\phone{+41 61 123 45 67} \phone{+41 61 123 45 67}
\email{petra@example.ch} \email{petra@example.ch}
\background{background.png} \background{background.png}
\photo{photo.png} \logo{photo.png}
\begin{document} \begin{document}
\drawcard \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} \documentclass[qreclevel=Q]{businesscard-qrcode}
% Demonstrates optional photo placement: % Demonstrates optional logo placement:
% - Default: photo appears next to name (auto-scaled to name height) % - Default: logo appears next to name (auto-scaled to name height)
% - Alternative: use photoinqr option to place photo in QR code center (requires qreclevel=H) % - 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: % 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} \givennames{Alex}
\familynames{Muster} \familynames{Muster}
Binary file not shown.
+2 -2
View File
@@ -1,5 +1,5 @@
% !TeX program = xelatex % !TeX program = xelatex
\documentclass[photoinqr,qrlogoscale=0.4,qreclevel=H]{businesscard-qrcode} \documentclass[logoinqr,qrlogoscale=0.4,qreclevel=H]{businesscard-qrcode}
\type{home} \type{home}
\givennames{Lisa\ Linda} \givennames{Lisa\ Linda}
@@ -12,7 +12,7 @@
\phone{+1 234 567 8900} \phone{+1 234 567 8900}
\email{ldoe@example.com} \email{ldoe@example.com}
\homepage{example.com} \homepage{example.com}
%\photo{photo.png} % uncomment if photo.png exists %\logo{photo.png} % uncomment if photo.png exists
\begin{document} \begin{document}
\drawcard \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} \type{home}
\givennames{Max} \givennames{Max}
\familynames{Muster} \familynames{Muster}
\additionalnames{Big\ Photo\ Example} \additionalnames{Big\ Logo\ Example}
\street{Beispielstrasse\ 42} \street{Beispielstrasse\ 42}
\city{Winterthur} \city{Winterthur}
\zip{8400} \zip{8400}
\country{CH} \country{CH}
\phone{+41 52 123 45 67} \phone{+41 52 123 45 67}
\email{max@example.ch} \email{max@example.ch}
\photo{photo.png} \logo{photo.png}
\background{background.png} \background{background.png}
\begin{document} \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