python - Preserve color with PIL when copy image -
i have code
# creating qr img = none img_io = stringio.stringio() img = qrcode.make('http://my-domain.com/scanned/'+str(s.pk)) img_w, img_h = img.size logo = image.open(settings.media_root+'logo.png', 'r') logo_w, logo_h = logo.size offset = ((img_w - logo_w) / 2, (img_h - logo_h) / 2) img.paste(logo, offset) img.save(img_io) qr_code = inmemoryuploadedfile(img_io, none, 'the-qr.jpg', 'image/jpeg', img_io.len, none)
the image 'logo.png' red color, when save final image in black , white, how can preserve rgb colours?
i have tried raises errors:
img.convert('rgb').save(img_io) file "/var/www/project/api/views.py", line 361, in perform_update img.convert('rgb').save(img_io) file "/usr/local/lib/python2.7/dist-packages/pil/image.py", line 1687, in save format = extension[ext] keyerror: ''
Comments
Post a Comment