[英]Rotate image with python-barcode ImageWriter in bytesIO stream
I want to rotate the image I have saved in bytesIO with python-barcode ImageWriter but its optional fields do not have this option我想用 python-barcode ImageWriter 旋转我保存在 bytesIO 中的图像,但它的可选字段没有这个选项
img = barcode.get_barcode(barcode_type, barcode_text, writer=ImageWriter())
fp = io.BytesIO()
img.write(fp, options={'module_width': 0.1, 'module_height': 1, 'font_size': 4, 'text_distance': 0.5,
'quiet_zone': 1, 'write_text': True})
I handled it with the pillow package, first saved the created image in memory and then rotated it using the pil.我是用pillow package处理的,先把创建好的图片保存在memory,然后用pil旋转一下。
from PIL import Image
pil_img = Image.open(fp)
pil_img = pil_img.rotate(90, expand=True)
fp = io.BytesIO()
pil_img.save(fp, format='JPEG')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.