Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 图像处理错误:模块';PIL.Image';没有属性';ImageWin';和';ImageDraw';_Python 3.x_Image Processing - Fatal编程技术网

Python 3.x 图像处理错误:模块';PIL.Image';没有属性';ImageWin';和';ImageDraw';

Python 3.x 图像处理错误:模块';PIL.Image';没有属性';ImageWin';和';ImageDraw';,python-3.x,image-processing,Python 3.x,Image Processing,我的目标是在我的图像上打印一个内外边框 外边框的像素数应为20,内边框的像素数应为10。我不确定为什么win=Image.ImageWin(img.getWidth(),img.getHeight())不起作用,而且img.ImageDraw(win): 我得到这个错误: 模块“PIL.Image”没有属性“ImageWin”和“ImageDraw” PS:我正在Windows操作系统上运行此功能。您的操作系统是什么?您现在正在使用windodws?Windows吗?如果您正在使用PIL/Pil

我的目标是在我的图像上打印一个内外边框

外边框的像素数应为20,内边框的像素数应为10。我不确定为什么
win=Image.ImageWin(img.getWidth(),img.getHeight())
不起作用,而且
img.ImageDraw(win)

我得到这个错误:

模块“PIL.Image”没有属性“ImageWin”和“ImageDraw”


PS:我正在Windows操作系统上运行此功能。

您的操作系统是什么?您现在正在使用windodws?Windows吗?如果您正在使用PIL/Pillow编写循环,则可能是出了问题。这篇文章应该可以帮助你添加一个边框。。。
from PIL import Image, ImageDraw, ImageWin

img = Image.open("Canada.jpg")
win = Image.ImageWin(img.getWidth(), img.getHeight())
img.ImageDraw(win)
img.setDelay(1,15)   # setDelay(0) turns off animation

for row in range(0,20):
    for col in range (img.getWidth()):
        p = img.getPixel(col,row)

        newred = 0
        newgreen = 0
        newblue = 0

        newpixel = Image.Pixel(newred, newgreen, newblue)
        img.setPixel(col,row,newpixel)

for row in range(224,img.getHeight()):
    for col in range(img.getWidth()):
        p = img.getPixel(col, row)

        newred = 0
        newgreen = 0
        newblue = 0

        newpixel = Image.Pixel(newred, newgreen, newblue)

        img.setPixel(col, row, newpixel)


img.draw(win)
win.exitonclick()