This project demonstrates two methods of generating QR codes using Python. The first method uses the qrcode library to create a simple QR code, while the second method uses the same library along with PIL to generate a customized QR code with specified colors.
- Simple QR Code Generation: Creates a basic QR code and saves it as an image file.
- Customized QR Code Generation: Generates a QR code with specified fill and background colors, and saves it as an image file.
- Python
- QR Code Generation
- Image Processing
- Python Imaging Library (PIL)
- Clone the repository:
git clone https://github.com/yourusername/qr-code-generation-project.git
- Navigate to the project directory:
cd qr-code-generation-project - Install the required packages:
pip install qrcode[pil]
- Open the
simple_qr.pyfile and replace the empty string inqr.make("")with your desired data. - Run the script to generate the QR code:
python simple_qr.py
- The QR code image will be saved as
twishapatel.png.
- Open the
custom_qr.pyfile and replace the URL inqr.add_data("http://localhost/wordpress/")with your desired data. - Modify the
fill_colorandback_colorparameters to customize the QR code colors. - Run the script to generate the customized QR code:
python custom_qr.py
- The customized QR code image will be saved as
colorQR1.png.
import qrcode as qr
img = qr.make("https://example.com")
img.save("example.png")from turtle import fillcolor
import qrcode
from PIL import Image
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_H,
box_size=10,
border=4
)
qr.add_data("https://example.com")
qr.make(fit=True)
img = qr.make_image(fill_color="yellow", back_color="green")
img.save("custom_example.png")- Python Software Foundation
- Libraries used:
qrcode,PIL
This project is licensed under the MIT License. See the LICENSE file for details.