【问题标题】:text_to_image - how to use (python3)text_to_image - 如何使用(python3)
【发布时间】:2019-11-09 04:52:13
【问题描述】:

我在 python3 中安装了this package。如何使用它?我按照说明进行操作,但出现以下错误:

linux@LINUXMINT:~/.local/lib/python3.6/site-packages/text_to_image$ python3 decode.py image.png
Traceback (most recent call last):
  File "decode.py", line 60, in <module>
    print(decode(args.image_path))
  File "decode.py", line 27, in decode
    decoded_text += chr(pixel_value)
TypeError: an integer is required (got type tuple)
linux@LINUXMINT:~/.local/lib/python3.6/site-packages/text_to_image$ python3 decode.py -f my-text-file.txt image.png
Traceback (most recent call last):
  File "decode.py", line 62, in <module>
    output_file = decode_to_file(args.image_path, args.file)
  File "decode.py", line 44, in decode_to_file
    decoded_text = decode(image_path)
  File "decode.py", line 27, in decode
    decoded_text += chr(pixel_value)
TypeError: an integer is required (got type tuple)

【问题讨论】:

  • 请提供出现错误的代码。

标签: python-3.x package


【解决方案1】:

我尝试了以下方法,效果很好:

$ python3 encode.py -t "Hello World!" image.png  # encodes given text
$
$ INFO:root:Image 'image.png' has been created


$ python3 decode.py image.png  # decodes a given image
$ 
$ Hello World!

确保使用库提供的 encode.py 和 decode.py。

【讨论】:

    猜你喜欢
    • 2019-10-10
    • 2015-09-01
    • 2012-08-08
    • 2016-02-06
    • 2021-08-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多