Fundamentals 4 min read

Generating Static and Animated QR Codes with Python MyQR Library

This tutorial demonstrates how to install the MyQR Python library, explains its key parameters, and provides step‑by‑step code examples for creating static QR codes, adding background images, and producing animated QR codes using .gif files.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
Generating Static and Animated QR Codes with Python MyQR Library

1. Code Practice

1.1 Module Installation

Install the required library with the command:

pip install MyQR

1.2 Parameter Explanation

The main parameters of MyQR are:

words : content of the QR code

version : size of the QR code, range [1,40]

picture : background image file (.jpg, .png, .bmp, .gif); default is black‑white

colorized : background color flag, default False (black‑white)

save_name : output file name, default qrcode.png save_dir : directory to save the file, default is the current working directory

1.3 Code Practice

1.3.1 Static QR Code

Simple example to generate a QR code:

# -*- coding:utf-8 -*-
# @Time   : 2021-09-30
# @Author : carl_DJ

from MyQR import myqr

# Define QR code content
word = "Carl"

# Generate QR code
myqr.run(word)

Running the script creates qrcode.png in the current directory.

Resulting QR code image:

Static QR code
Static QR code

1.3.2 Adding a Background Image

Prepare a background picture and modify the code:

# -*- coding:utf-8 -*-
# @Time   : 2021-09-30
# @Author : carl_DJ

from MyQR import myqr

word = "Carl"

myqr.run(
    word,
    picture='./wf.png',
    colorized=True,
    version=6
)

The generated QR code now includes the specified background image.

QR code with background
QR code with background

1.3.3 Animated QR Code

To create an animated QR code, simply replace the background image with a .gif file:

# -*- coding:utf-8 -*-
# @Time   : 2021-09-30
# @Author : carl_DJ

from MyQR import myqr

word = "miss U "

myqr.run(
    word,
    picture='./sohucs.gif',
    colorized=True,
    version=6
)

The output is an animated QR code that cycles through the frames of the provided GIF.

Animated QR code
Animated QR code

In summary, generating both static and animated QR codes with MyQR only requires adjusting the picture parameter (using .png for static and .gif for animated) while keeping other arguments unchanged.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

QR codemyqr
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.