我有一个应该调整图像大小的python方法
def Reformat_Image(ImageFilePath,fileName,image):
print("inside Reformat_Image")
image_size = image.size
width = image_size[0]
print
height = image_size[1]
if(width != height):
bigside = width if width > height else height
background = Image.new('RGBA', (bigside, bigside), (255, 255, 255, 255))
offset = (int(round(((bigside - width) / 2), 0)), int(round(((bigside - height) / 2),0)))
background.paste(image, offset)
background.save(fileName+"Resized.jpg")
print("Image has been resized")
当我打电话使用它时
cwd = os.getcwd()
print("Resizing picture")
Reformat_Image(ImageFilePath =image_path,fileName=fileName,image=image)
Reformat_Image()方法的内部永远不会运行。在运行该代码之前,我能够成功打开图像几行,因此我认为我的文件名/位置应该可以正常工作。在命令提示符下,我得到“调整图片大小”,但没有得到“内部Reformat_Image”