我正在尝试使用将 TIFF 转换为 PNG PythonMagick
,这是代码
from PythonMagick import Image
from PIL import Image
sImage = 'MySample.tiff'
sOutput = 'MyOutput.png'
sCropped = 'Cropped.png'
def crop(img, image_path, coords, saved_location):
Image(img).write(image_path)
image_obj = Image.open(image_path)
cropped_image = image_obj.crop(coords)
cropped_image.save(saved_location)
# cropped_image.show()
if __name__ == '__main__':
crop(sImage, sOutput, (440, 145, 770, 195), sCropped)
我遇到了这样的错误
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-16-f77d54075818> in <module>
14
15 if __name__ == '__main__':
---> 16 crop(sImage, sOutput, (440, 145, 770, 195), sCropped)
<ipython-input-16-f77d54075818> in crop(img, image_path, coords, saved_location)
7
8 def crop(img, image_path, coords, saved_location):
----> 9 Image(img).write(image_path)
10 image_obj = Image.open(image_path)
11 cropped_image = image_obj.crop(coords)
TypeError: 'module' object is not callable
知道如何解决这样的错误吗?