You've already forked amazing-qr
mirror of
https://github.com/x-hw/amazing-qr.git
synced 2025-07-15 01:24:37 +02:00
Merge pull request #10 from northlandsnow/fix/keep-duration
keep duration with origin gif file
This commit is contained in:
@ -22,8 +22,8 @@ from PIL import Image
|
|||||||
def run(words, version=1, level='H', picture=None, colorized=False, contrast=1.0, brightness=1.0, save_name=None, save_dir=os.getcwd()):
|
def run(words, version=1, level='H', picture=None, colorized=False, contrast=1.0, brightness=1.0, save_name=None, save_dir=os.getcwd()):
|
||||||
|
|
||||||
supported_chars = r"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ··,.:;+-*/\~!@#$%^&`'=<>[]()?_{}|"
|
supported_chars = r"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ··,.:;+-*/\~!@#$%^&`'=<>[]()?_{}|"
|
||||||
|
|
||||||
|
|
||||||
# check every parameter
|
# check every parameter
|
||||||
if not isinstance(words, str) or any(i not in supported_chars for i in words):
|
if not isinstance(words, str) or any(i not in supported_chars for i in words):
|
||||||
raise ValueError('Wrong words! Make sure the characters are supported!')
|
raise ValueError('Wrong words! Make sure the characters are supported!')
|
||||||
@ -97,6 +97,7 @@ def run(words, version=1, level='H', picture=None, colorized=False, contrast=1.0
|
|||||||
import imageio
|
import imageio
|
||||||
|
|
||||||
im = Image.open(picture)
|
im = Image.open(picture)
|
||||||
|
duration = im.info.get('duration', 0)
|
||||||
im.save(os.path.join(tempdir, '0.png'))
|
im.save(os.path.join(tempdir, '0.png'))
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
@ -113,7 +114,7 @@ def run(words, version=1, level='H', picture=None, colorized=False, contrast=1.0
|
|||||||
|
|
||||||
ims = [imageio.imread(pic) for pic in imsname]
|
ims = [imageio.imread(pic) for pic in imsname]
|
||||||
qr_name = os.path.join(save_dir, os.path.splitext(os.path.basename(picture))[0] + '_qrcode.gif') if not save_name else os.path.join(save_dir, save_name)
|
qr_name = os.path.join(save_dir, os.path.splitext(os.path.basename(picture))[0] + '_qrcode.gif') if not save_name else os.path.join(save_dir, save_name)
|
||||||
imageio.mimsave(qr_name, ims)
|
imageio.mimwrite(qr_name, ims, '.gif', **{ 'duration': duration/1000 })
|
||||||
elif picture:
|
elif picture:
|
||||||
qr_name = combine(ver, qr_name, picture, colorized, contrast, brightness, save_dir, save_name)
|
qr_name = combine(ver, qr_name, picture, colorized, contrast, brightness, save_dir, save_name)
|
||||||
elif qr_name:
|
elif qr_name:
|
||||||
|
Reference in New Issue
Block a user