Python jython在线打开图像
对于我的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
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\中没有文件错误是:参数值不正确(类型正确)。试图将参数传递给函数时出错。