2

我有一台 16 核的机器,但我当前的调整大小功能只使用一个核心,这对于大型图像目录来说效率非常低。

def generateThumbnail(self, width, height):
     """
     Generates thumbnails for an image
     """
     im = Image.open(self._file)
     (detected_width,detected_height) = im.size

     #Get cropped box area
     bbox = self.getCropArea(detected_width, detected_height, width, height)

     #Crop to box area
     cropped_image = im.crop(bbox)

     #Resize to thumbnail
     cropped_image.thumbnail((width, height), Image.ANTIALIAS)

     #Save image
     cropped_image.save(self._path + str(width) + 'x' +
             str(height) + '-' + self._filename, "JPEG")

任何帮助将不胜感激。谢谢你。

4

1 回答 1

5

对于使用线程接口但创建单独的进程而不是线程的多处理模块来说,这听起来是一个很好的解决方案。

于 2010-11-01T04:23:08.090 回答