Python copy on PIL image object -
i'm trying create set of thumbnails, each 1 separately downscaled original image.
image = image.open(path) image = image.crop((left, upper, right, lower)) size in sizes: temp = copy.copy(image) temp.thumbnail((size, height), image.antialias) temp.save('%s%s%s.%s' % (path, name, size, format), quality=95)
the above code seemed work fine while testing discovered images (i can't tell what's special them, maybe png) raise error:
/usr/local/lib/python2.6/site-packages/pil/pngimageplugin.py in read(self=<pil.pngimageplugin.pngstream instance>) line: s = self.fp.read(8) <type 'exceptions.attributeerror'>: 'nonetype' object has no attribute 'read'
without copy()
these images work fine.
i open , crop image anew every thumbnail, i'd rather have better solution.
i guess copy.copy()
not work pil image
class. try using image.copy()
instead, since there reason:
image = image.open(path) image = image.crop((left, upper, right, lower)) 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)
Comments
Post a Comment