python - Using Image (PIL) to save the file marked a difference between 2 pictures -
i comparing 2 pictures , want mark difference , save in new file.
(python 2.7 + windows)
what doing below:
from pil import image pil import imagechops pil import imagedraw file1 = 'animal nov 2014.jpg' file2 = ' animal may 2014.jpg' im1 = image.open(file1) im2 = image.open(file2) diff = imagechops.difference(im1, im2).getbbox() draw = imagedraw.draw(im2) draw.rectangle(diff) im2.save('file3.jpg')
when save 'file3.jpg', gives error:
ioerror: cannot write mode p jpeg
when save 'file3.png', gives error:
typeerror: integer required
how can have saved new file? thanks.
please see solution @ pil (image) valueerror: not valid number of quantization tables. should between 1 , 4
the reply can found in thread: getting " cannot write mode p jpeg" while operating on jpg image
you need convert image rgb mode.
in case:
im2.convert('rgb').save('file3.jpg')
python image python-imaging-library
No comments:
Post a Comment