用python在单个TIFF文件中保存多个图像

用python在单个TIFF文件中保存多个图像,python,image,append,python-imaging-library,tiff,Python,Image,Append,Python Imaging Library,Tiff,我有多个图像,我想在TIFF文件中保存每22个图像。我发现我应该先保存图像,然后将它们加载到TIFF文件中保存。我想保存每个裁剪的图像,直到文件包含22个图像。我花了两个多星期的时间试图找到我能做到这一点的方法 任何帮助都将不胜感激 代码: for i, ci in enumerate(coefficients): plt.imshow(ci.reshape(1, -1), extent=[0, 3844, i + 0.5, i +1.5], cmap='inferno', as

我有多个图像,我想在TIFF文件中保存每22个图像。我发现我应该先保存图像,然后将它们加载到TIFF文件中保存。我想保存每个
裁剪的
图像,直到文件包含22个图像。我花了两个多星期的时间试图找到我能做到这一点的方法

任何帮助都将不胜感激

代码

for i, ci in enumerate(coefficients):
        plt.imshow(ci.reshape(1, -1), extent=[0, 3844, i + 0.5, i +1.5], cmap='inferno', aspect='auto', interpolation='nearest')
        plt.ylim(0.5, len(coeffs)-0.5) 
        plt.yticks(range(1, len(coeffs)), ['cD5', 'cD4', 'cD3', 'cD2', 'cD1'])  

plt.axis('off')
 
plt.savefig(FirstPartPathOutput+SecondPartPathOutput+'/spec_'+isPreictal+'_'+str(nSpectogram+1)+'_'+str(k)+'.png')
for image in filePaths :
        image=Image.open(filePath)
        image.load()
        imageSize = image.size
   # remove alpha channel
        invert_im = image.convert("RGB") 
    # invert image (so that white is 0)
        invert_im = ImageOps.invert(invert_im)
        imageBox = invert_im.getbbox()
        cropped=image.crop(imageBox)