Python copy on PIL image object

前端 未结 1 1350
你的背包
你的背包 2021-01-03 19:10

I\'m trying to create a set of thumbnails, each one separately downscaled from the original image.

image = Image.open(path)
image = image.crop((left, upper,          


        
相关标签:
1条回答
  • 2021-01-03 19:42

    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)
    
    0 讨论(0)
提交回复
热议问题