2

私は16コアのマシンを持っていますが、現在のサイズ変更機能は1つのコアしか使用していません。これは、画像の大きなディレクトリには非常に非効率的です。

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 に答える