Generate a QR code for any URL, with an optional logo or image centred on top. The script produces a high-resolution PNG, and when a logo is provided it overlays your branding with error correction to ensure the code still scans reliably. Perfect for marketing materials, business cards, and product packaging.
Features
- Generates a QR code for any URL
- Optionally overlays your logo or image in the centre with a clean white padding border
- Configurable QR size, logo size percentage, and error correction level
- Supports PNG, JPG, and WebP logos (WebP auto-converted via ImageMagick)
- Auto-downloads the QRCoder library on first run — no manual setup needed
- Outputs a high-quality PNG file
Usage
Basic usage — QR code without a logo
qr-code.ps1 -Url "https://example.com"
Add a logo in the centre
qr-code.ps1 -Url "https://example.com" -LogoPath "logo.png"
Custom output path and QR size
qr-code.ps1 -Url "https://example.com" -LogoPath "logo.png" -OutputPath "my-qr.png" -QRSize 30
Adjust logo size (percentage of QR code) and error correction
qr-code.ps1 -Url "https://example.com" -LogoPath "logo.png" -LogoSizePercent 25 -ErrorCorrection 3
Parameters
| Parameter | Default | Description |
|—————–|————|——————-|
| `-Url` | *(required)* | The URL to encode in the QR code |
| `-LogoPath` | *(optional)* | Path to your logo image (PNG, JPG, or WebP) |
| `-OutputPath` | qr.png | Output filename |
| `-QRSize` | 20 | Pixel size per QR module (higher = larger image) |
| `-LogoSizePercent` | 20 | Logo size as a percentage of the QR code |
| `-ErrorCorrection` | 2 | Error correction level: 0 (Low), 1 (Medium), 2 (Quartile), 3 (High) |
Requirements
- Windows with PowerShell 5.1 or later (included with Windows 10/11)
- QRCoder NuGet package — automatically downloaded on first run (no action needed)
- ImageMagick — only needed if your logo is a WebP file (optional)
Installing ImageMagick (Only for WebP Logos)
If you want to use a WebP image as your logo, you’ll need ImageMagick installed:
- Download the installer from [https://imagemagick.org/script/download.php#windows](https://imagemagick.org/script/download.php#windows) — choose the top “Win64 dynamic” `.exe` installer.
- Run the installer. On the “Select Additional Tasks” screen, make sure “Add application directory to your system path” is checked.
- Restart any open terminal/PowerShell windows.
- Verify by running: `magick –version`
Running PowerShell Scripts
If you haven’t run PowerShell scripts before, you may need to allow it once. Open PowerShell as Administrator and run:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Then navigate to the folder containing the script and run it.
Adding the Script to Your PATH (Optional)
For convenience, you can add the folder containing the script to your system PATH so you can run it from any directory:
- Press Win + S and search for “Environment Variables”
- Click “Edit the system environment variables”
- Click Environment Variables at the bottom
- Under User variables, select Path and click Edit
- Click New and paste the full path to the folder where you saved the script (e.g. `C:\Scripts`)
- Click OK on all dialogs
- Restart any open terminal windows
You can now run `qr-code.ps1` from anywhere without navigating to the script’s folder first.
Free download — if you find it useful, consider supporting development