简体   繁体   English

在 bytesIO stream 中使用 python-barcode ImageWriter 旋转图像

[英]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.

相关问题 如何使用变量生成带有 python-barcode 的条码 - How can I use a variable to generate barcode with python-barcode “python-barcode”库中的错误条形码格式 - Wrong barcode format from “python-barcode” library 如何在 Python 3 中使用条形码库中的 ImageWriter 特殊选项? - How to use ImageWriter special options from barcode library in Python 3? gnupg-解密为Python bytesio流 - gnupg - decrypt into Python bytesio stream 使用 python-barcode 尝试生成条形码并收到错误消息:AttributeError: 'function' object has no attribute 'get' - Using python-barcode trying to generate barcode and got error message: AttributeError: 'function' object has no attribute 'get' ftp发送python bytesio流 - ftp sending python bytesio stream Ananconda, Windows, Python3.8 & python-barcode; 间歇性地得到:[SpyderKernelApp] 警告 | 没有这样的通信: - Ananconda, Windows, Python3.8 & python-barcode; intermittently get: [SpyderKernelApp] WARNING | No such comm: 上传 SimpleUploadedFile 时 BytesIO 流图像为空白 - BytesIO stream image is blank when uploading SimpleUploadedFile 使用pybarcode ImageWriter和docx模块将条形码图像附加到docx文件 - Append barcode images to docx file using pybarcode ImageWriter and docx module BytesIO对象到图像 - BytesIO object to image
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM