--- ImageArchive/ImageArchive.py 2006/05/22 15:29:33 1.90 +++ ImageArchive/ImageArchive.py 2006/05/22 21:09:53 1.92 @@ -25,7 +25,7 @@ import Queue import cgi import sys import zLOG - +import shutil from AccessControl import ClassSecurityInfo, getSecurityManager @@ -515,11 +515,17 @@ class ImageDigilib(Folder,Persistent,Imp zLOG.LOG("ImageArchive:scaleToJpg", zLOG.ERROR, "%s "%newName) return False - - - - - self.scale(dest=self.srcBasis,filename=newName,scaleBy=1,RESPONSE=RESPONSE) + ext= os.path.splitext(imagePath)[1].lower() + if ext.rstrip()==".jpg": + shutil.copy(newName,imagePath) + print "copy",imagePath + return True + + print "SCALED",imagePath + dest="/Volumes/paviaExtern/docuserver/images/exhibitionImages/" + dir=self.getId() + src=path + self.scale(dest=dest,dir=dir,src=path,scaleBy=1,RESPONSE=RESPONSE) return True def updateImage(self,_fileupload,_rename=None,RESPONSE=None): @@ -699,15 +705,18 @@ class ImageCollection(OrderedFolder, Per destBasis="/docuserver/scaled/" srcBasis="/docuserver/images" - def scale(self,dest=None,dir=None,filename=None,scaleTo=None,scaleBy=None,RESPONSE=None): + def scale(self,dest=None,dir=None,src=None,scaleTo=None,scaleBy=None,RESPONSE=None): """scaler""" #scaleomatStr="ssh nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat.pl -src=/mpiwg/online/ %s" scaleomatStr="/docuserver/libs/scaleomat/scaleomat.pl" destBasis=self.destBasis srcBasis=self.srcBasis - - srcStr=" -src=%s"%srcBasis + if src: + srcStr=" -src=%s"%src + else: + srcStr=" -src=%s"%srcBasis + scaleStr=scaleomatStr+srcStr if dir: dirTmp=dir.replace(srcBasis,'') @@ -738,9 +747,9 @@ class ImageCollection(OrderedFolder, Per zLOG.LOG("ImageCollection:scale",zLOG.ERROR,"no destionation given") return False - print scaleStr - ret=scaleStr - #ret=os.popen(scaleStr) + + #ret=scaleStr + ret=os.popen2(scaleStr,1)[1].read() if RESPONSE: RESPONSE.write(ret) @@ -867,7 +876,7 @@ class ImageCollection(OrderedFolder, Per def scaleToJpgs(self,RESPONSE=None): """scale all tifs to jps""" - print self._objects + for x in self._objects: if (not hasattr(getattr(self,x['id']),'scaleToJpg')) or (not getattr(self,x['id']).scaleToJpg()): @@ -1156,8 +1165,9 @@ class ImageCollection(OrderedFolder, Per ret="" #print self.__dict__ for file in files: - if not file[0]==".": - if self.__dict__.has_key(file): + fn=os.path.splitext(file)[0] + if not (file[0]=="."): + if self.__dict__.has_key(file) or self.__dict__.has_key(fn+'.tif') or self.__dict__.has_key(fn+'.tiff') : ret=ret+"
"+file+" already exists!" else: @@ -1242,10 +1252,12 @@ class ImageCollection(OrderedFolder, Per ret="" #print self.__dict__ for file in files: - if not file[0]==".": - if self.__dict__.has_key(file): + fn=os.path.splitext(file)[0] + if not (file[0]=="."): + if self.__dict__.has_key(file) or self.__dict__.has_key(fn+'.tif') or self.__dict__.has_key(fn+'.tiff') : ret=ret+"
"+file+" already exists!" + else: ret=ret+"
"+file+" created!" newObj=ImageDigilib(file,file) @@ -1859,10 +1871,13 @@ class ImageCollectionMD(ImageCollection, ret="" #print self.__dict__ for file in files: - if not file[0]==".": - if self.__dict__.has_key(file): + + if not (file[0]=="."): + fn=os.path.splitext(file)[0] + if self.__dict__.has_key(file) or self.__dict__.has_key(fn+'.tif') or self.__dict__.has_key(fn+'.tiff') : ret=ret+"
"+file+" already exists!" + else: ret=ret+"
"+file+" created!" newObj=ImageDigilib(file,file)