Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/340.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 jython在线打开图像_Python_Jython_Urllib_Urlopen_Jes - Fatal编程技术网

Python jython在线打开图像

Python jython在线打开图像,python,jython,urllib,urlopen,jes,Python,Jython,Urllib,Urlopen,Jes,对于我的Python大学课程,我尝试从在线打开一个图像,添加到另一个图像(使用Jython)。到目前为止,我的代码是: def addLogo(lgPic): import urllib logo = urllib.urlopen("http://www.wsiab.net/BITsoft/Lab7/csumb-logo-white.png") targetX = getWidth(lgPic) - getWidth(logo) targetY = getHeight(lgPic

对于我的Python大学课程,我尝试从在线打开一个图像,添加到另一个图像(使用Jython)。到目前为止,我的代码是:

def addLogo(lgPic):
  import urllib
  logo = urllib.urlopen("http://www.wsiab.net/BITsoft/Lab7/csumb-logo-white.png")
  targetX = getWidth(lgPic) - getWidth(logo)
  targetY = getHeight(lgPic) - getHeight(logo)
  for x in range(0, getWidth(logo)):
    for y in range(0, getHeight(logo)):
      pix = getPixel(logo, x, y)
      bPix = getPixel(lgPic, x + targetX, y + targetY)
      color = getColor(pix)
      bColor = getColor(bPix)
      if distance(color, Color(0, 215, 0)) > 50:
        newPix = getPixel(lgPic, x + targetX, y + targetY)
        setColor(bPix, color)
  return lgPic
这将返回错误:

getWidth(图片):输入不是图片 错误是: 参数值不正确(类型正确)。 试图将参数传递给函数时出错


如何简单地将此图像引入并使用它?

我还尝试了'logo=makePicture(urllib.urlopen(“)'在哪里定义了
getWidth
呢?getWidth()是Jython的一部分。如果我从HDD打开一个图像,它可以工作,但我不知道如何以同样的方式使用在线图像。
logo=makePicture(“http://www.wsiab.net/BITsoft/Lab7/csumb-logo-white.png“”
返回:makePicture(文件名):在C:\Program Files(x86)\JES 4.3\中没有文件错误是:参数值不正确(类型正确)。尝试将参数传递给函数时出错。我还尝试了“logo=makePicture(urllib.urlopen(“)”'其中定义了
getWidth
吗?getWidth()是Jython的一部分。如果我从硬盘上打开一个图像,它会工作,但我不知道如何以同样的方式使用在线图像http://www.wsiab.net/BITsoft/Lab7/csumb-logo-white.png“”返回:makePicture(文件名):在C:\Program Files(x86)\JES 4.3\中没有文件错误是:参数值不正确(类型正确)。试图将参数传递给函数时出错。