A sophisticated Python web application that generates customizable and visually appealing QR codes. This project combines functionality with aesthetics, allowing users to create unique QR codes with custom colors, backgrounds, and gradient effects.
Author: Muhammad Husnain Ali
Repository: QR_Code_Generator
This Fancy QR Code Generator is a web-based application that elevates the standard QR code creation process by adding customization options and visual enhancements. Built with Python and Streamlit, it offers an intuitive interface for creating visually striking QR codes suitable for business and personal use.
- Custom Colors: Choose custom colors for QR code and background
- Background Images: Add custom background images to QR codes
- Gradient Effects: Apply gradient overlays for unique visual effects
- Real-time Preview: Instant visualization of QR code changes
- High Quality Output: Generate high-resolution QR codes suitable for print and digital use
- Python 3.7 or later
- Streamlit
- qrcode
- Pillow (PIL)
- numpy
- Web browser with modern features support
-
Clone the Repository
git clone https://github.com/M-Husnain-Ali/QR_Code_Generator.git cd QR_Code_Generator
-
Set Up Virtual Environment
# Windows python -m venv venv .\venv\Scripts\activate # Linux/macOS python3 -m venv venv source venv/bin/activate
-
Install Dependencies
# Install all required packages from requirements.txt pip install -r requirements.txt
Dependencies included:
- streamlit - Web application framework
- qrcode - QR code generation library
- Pillow - Image processing library
- numpy - Numerical computing library
-
Run the Application
streamlit run qrscanner.py
-
Deactivate Virtual Environment When Done
deactivate
-
Color Selection
- Custom QR code colors with color picker
- Custom background colors with color picker
- Default black QR code on white background
- Gradient overlay effects for modern look
-
Background Options
- Solid color backgrounds
- Custom image backgrounds (supports jpg, jpeg, png)
- Semi-transparent QR code overlay (128 alpha)
- Background image size auto-adjustment
- Error correction (Level M) for reliable scanning
- Automatic size optimization (version 1 QR code)
- 10x10 box size for clear visibility
- 4-unit border for proper scanning
- High-resolution PNG output
- Real-time preview generation
- Gradient alpha compositing
- Intuitive color pickers for QR and background
- Simple file upload system for backgrounds
- Live preview updates
- Responsive design with custom CSS
- User-friendly controls and warnings
- Modern pink-themed UI elements
Application
├── User Interface (Streamlit)
│ ├── Input Components
│ │ ├── Text Input
│ │ ├── Color Pickers
│ │ ├── Background Selector
│ │ └── File Uploader
│ └── Output Components
│ ├── QR Code Display
│ └── Warning Messages
├── QR Generation (qrcode)
│ ├── Data Encoding
│ ├── Error Correction
│ └── Size Optimization
└── Image Processing (PIL)
├── Background Integration
├── Transparency Control
└── Gradient Effects
-
QR Code Generation (
generate_fancy_qr_code
)def generate_fancy_qr_code(data, color, background_color, background_image, gradient_colors): # Generates QR code with customization options # Parameters: # - data: String to encode # - color: QR code color (hex) # - background_color: Background color (hex) # - background_image: Optional PIL Image # - gradient_colors: Boolean for gradient effect
- Version control (version=1)
- Error correction (ERROR_CORRECT_M)
- Size optimization (box_size=10, border=4)
- Custom color support
- Background image integration
- Gradient effect processing
-
Image Processing
- Background image handling
- RGBA color space conversion
- Alpha channel manipulation
- Gradient overlay generation
- Image composition and blending
- PNG format output generation
-
User Interface
- Custom CSS styling
- Input validation
- Real-time updates
- Error handling
- Preview generation
- Responsive layout
-
Launch the Application
- Activate virtual environment
- Run Streamlit server
- Access via web browser
- Note the custom page title and icon
-
Create QR Code
- Enter URL or text data
- Select QR code color using picker
- Choose background style:
- Plain color with picker
- Upload custom image
- Toggle gradient effect if desired
-
Customize Appearance
- Use color pickers for precise colors
- Upload background image (jpg/jpeg/png)
- Enable gradient for modern look
- Preview changes in real-time
-
Generate and Save
- Click "Generate Fancy QR Code"
- View preview with auto-width
- Save generated PNG file
- Test QR code with scanner
QR_Code_Generator/
├── qrscanner.py # Main application file
├── requirements.txt # Project dependencies
├── .gitignore # Git ignore configuration
└── README.md # Project documentation
-
qrscanner.py
- Main application logic
- QR code generation functions
- Streamlit UI implementation
- Image processing utilities
-
requirements.txt
- Project dependencies
- Required Python packages
- Version specifications
- Easy installation via pip
-
.gitignore
- Git version control configuration
- Ignores Python build files
- Excludes virtual environment
- Ignores IDE-specific files
- Prevents committing generated QR codes
- Excludes system and cache files
-
README.md
- Project documentation
- Installation instructions
- Usage guidelines
- Feature documentation
- Technical details
Contributions are welcome! Here are some ways you can contribute:
-
Improve the UI
- Add more color themes
- Implement new gradient styles
- Enhance mobile responsiveness
-
Add Features
- Support for more QR code versions
- Additional error correction levels
- More background effects
- Export in different formats
-
Code Quality
- Add unit tests
- Improve error handling
- Optimize image processing
- Add type hints
-
Documentation
- Add code comments
- Improve README
- Create user guide
- Add API documentation