python - 通过我的代码运行 GIF 时,如何解决此属性错误?
问题描述
完整代码链接:https ://paste.pythondiscord.com/pufabezuca.py
这是错误:
文件“C:\Users\User.spyder-py3\untitled0.py”,第 263 行,在 dct_img_encoded = DCT().encode_image(dct_img, secret_msg)
文件“C:\Users\User.spyder-py3\untitled0.py”,第 41 行,在 encode_image 行中,col = img.shape[:0]
AttributeError:“NoneType”对象没有属性“形状”
def encode_image(self,img,secret_msg):
# show(img)
secret=secret_msg
self.message = str(len(secret))+'*'+secret
self.bitMess = self.toBits()
# Get size of image in pixels
row,col = img.shape[:0]
self.oriRow, self.oriCol = row, col
if((col/8)*(row/8)<len(secret)):
print("Error: Message too large to encode in image")
return False
# Make divisible by 8x8
if row%8 != 0 or col%8 != 0:
img = self.addPadd(img, row, col)
row,col = img.shape[:2]
# Split image into RGB channels
bImg,gImg,rImg = cv2.split(img)```
解决方案
推荐阅读
- c++ - 错误:对象之前的预期类型说明符
- python - 获取 td 标签的值
- python - PyTorch 使用没有 For 循环的核函数生成矩阵
- arrays - 如何缩写 if 或嵌套公式
- javascript - 为什么 map 或 for 循环在返回对象时没有给出它的索引
- ruby-on-rails - 我们可以在搜索结果上使用什么回调
- java - 如何使用spring boot在soap响应中启用默认WS-Addressing
- homebrew - youtube-dl 的自制软件和 wget 安装有什么区别?
- python - TypeError 返回模型条目
- r - 使用 TukeyHSD 的输出自动将重要字母添加到 ggplot 条形图