且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PIL图像对象上的Python复制

更新时间:2023-10-23 16:29:22

我猜copy.copy()对于PIL Image类不起作用.尝试使用Image.copy()代替,因为它存在是有原因的:

I guess copy.copy() does not work for the PIL Image class. Try using Image.copy() instead, since it is there for a reason:

image = Image.open(path)
image = image.crop((left, upper, right, lower))
for size in sizes:
  temp = image.copy()  # <-- Instead of copy.copy(image)
  temp.thumbnail((size, height), Image.ANTIALIAS)
  temp.save('%s%s%s.%s' % (path, name, size, format), quality=95)