在Freeimagepy中创建多重tif,内存未被释放

时间:2017-05-18 01:28:45

标签: python image tiff

我已经创建了一个程序,将TIF与2009年的FreeImagePy相当旧的版本合并为多个tifs。它实际上工作得很好,但我有一个小故障。最好的我可以告诉它不要释放内存并最终崩溃。谁能告诉我我错过了什么?

使用Ptyhon 2.7。

import urllib
import FreeImagePy as FIPY
import os.path
import time

# set source files
sourceFile = open('C:\\temp\AGetStatePlats\\PlatsGenesee.csv','r')
# logfile currently gets totally replaced at each run
logFile = open('C:\\temp\\AGetStatePlats\\PlatTifMerge.txt','w')
sourcePath = "c:\\temp\subdownload2\\"
destPath = 'C:\\temp\\subtifMerge\\'

for row in sourceFile:
        # prepare filenames
        subPath = row.split(',',1)[0]
        platID = subPath.split('/',1)[1]
        curDocument = sourcePath + platID + '01.tif'
        curPage = 0
        # check if base file is out there
        if not os.path.isfile(destPath + platID + '.tif'):
                outImage = FIPY.Image()
                outImage.new(multiBitmap = destPath + platID +'.tif')
                print (destPath + platID +'.tif')
                for n in range (1,100):
                        #build n
                        nPad = "{:0>2}".format(n)
                        if os.path.isfile(sourcePath + platID + nPad + '.tif'):
                              # delay in case file system is not keeping up may not be needed  
                              time.sleep (1.0/4.0)  
                              outImage.appendPage(sourcePath + platID + nPad + '.tif')
                              curPage = curPage + 1
                        else:
                              outImage.deletePage(0)          
                              outImage.close()
                              del outImage
                              logFile.write(sourcePath + platID + '.tif' + '\r')
                              logFile.write(platID + " PageCount = " + str(curPage) + '\r' )
                              break
        else:
                logFile.write(platID + " already exists" + '\r')
# cleanup

sourceFile.close()
logFile.close()

print("Run Complete!")

这是错误消息:

C:\ temp \ subtifMerge \ 05848.tif('错误返回。',' TIFF','警告:解析错误。图片可能不完整或包含无效数据!')回溯(最近一次调用最后一次):文件" C:\ temp \ AGetStatePlats \ PlatTIFcombine.py",第43行,在outImage.appendPage(sourcePath + platID + nPad +& #39; .tif')文件" C:\ Python27 \ ArcGIS10.4 \ lib \ site-packages \ FreeImagePy \ FreeIm ?? agePy.py",第2048行,在appendPage bitmap = self中。 genericLoader(fileName)File" C:\ Python27 \ ArcGIS10.4 \ lib \ site-packages \ FreeImagePy \ FreeIm ?? agePy.py",第1494行,在genericLoader dib = self.Load(fif,fileName) ,旗);文件" C:\ Python27 \ ArcGIS10.4 \ lib \ site-packages \ FreeImagePy \ FreeIm ?? agePy.py",第188行,在Load return self .__ lib.Load(typ,fileName,flags)

WindowsError:exception:priviledged instruction>>>

0 个答案:

没有答案