Example #1
0
 def resaveExistingImage(self):
     "reisze existing images"
     if self.exists():
         filename, remove_after = utility.createTempFile(self.image.data)
         content_type = magicfile.magic(filename)
         if content_type.startswith('image'):
             temp_file, x, y = utility.resaveExistingImage(filename)
             beforeSize = utility.fileSizeToInt(self.getFileSize())
             if temp_file is not None and os.stat(temp_file.name)[stat.ST_SIZE] < beforeSize:
                 self.image.manage_upload(temp_file)
                 self.image.width = x
                 self.image.height = y
                 #have to redo the content_type after we modify the image in case it has changed
                 content_type = magicfile.magic(temp_file.name)
                 temp_file.close()
                 self.setFileSize()
                 self.image.content_type = content_type
         utility.removeTempFile(filename, remove_after)
Example #2
0
 def resaveExistingImage(self):
     "reisze existing images"
     if self.exists():
         filename, remove_after = utility.createTempFile(self.image.data)
         content_type = magicfile.magic(filename)
         if content_type.startswith('image'):
             temp_file, x, y = utility.resaveExistingImage(filename)
             beforeSize = utility.fileSizeToInt(self.getFileSize())
             if temp_file is not None and os.stat(
                     temp_file.name)[stat.ST_SIZE] < beforeSize:
                 self.image.manage_upload(temp_file)
                 self.image.width = x
                 self.image.height = y
                 #have to redo the content_type after we modify the image in case it has changed
                 content_type = magicfile.magic(temp_file.name)
                 temp_file.close()
                 self.setFileSize()
                 self.image.content_type = content_type
         utility.removeTempFile(filename, remove_after)
Example #3
0
 def resaveExistingImage(self):
     "reisze existing images"
     if self.exists():
         filename, remove_after = utility.createTempFile(self.data.data)
         content_type = magicfile.magic(filename)
         if content_type.startswith('image'):
             if self.getConfig('resaveOnUpload'):
                 temp_file,x,y = utility.resaveExistingImage(filename)
                 beforeSize = utility.fileSizeToInt(self.getFileSize())
                 if temp_file is not None and os.stat(temp_file.name)[stat.ST_SIZE] < beforeSize:
                     if not self.data:
                         self.manage_addProduct['Image'].manage_addImage('data', temp_file, 'data')
                     else:
                         self.data.manage_upload(temp_file)
                     self.data.width = x
                     self.data.height = y
                     #have to redo the content_type after we modify the image in case it has changed
                     content_type = magicfile.magic(temp_file.name)
                     temp_file.close()
                     self.setFileSize()
                     self.storeContentType(content_type)
         utility.removeTempFile(filename, remove_after)
Example #4
0
 def resaveExistingImage(self):
     "reisze existing images"
     if self.exists():
         filename, remove_after = utility.createTempFile(self.data.data)
         content_type = magicfile.magic(filename)
         if content_type.startswith('image'):
             if self.getConfig('resaveOnUpload'):
                 temp_file, x, y = utility.resaveExistingImage(filename)
                 beforeSize = utility.fileSizeToInt(self.getFileSize())
                 if temp_file is not None and os.stat(
                         temp_file.name)[stat.ST_SIZE] < beforeSize:
                     if not self.data:
                         self.manage_addProduct['Image'].manage_addImage(
                             'data', temp_file, 'data')
                     else:
                         self.data.manage_upload(temp_file)
                     self.data.width = x
                     self.data.height = y
                     #have to redo the content_type after we modify the image in case it has changed
                     content_type = magicfile.magic(temp_file.name)
                     temp_file.close()
                     self.setFileSize()
                     self.storeContentType(content_type)
         utility.removeTempFile(filename, remove_after)