我有一台 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")
任何帮助将不胜感激。谢谢你。