python - PIL paste image with alpha appears faded -
i working multiple images stack on top of each other create single image. however, in working them, i'm noticing if image has transparency (alpha != 255), part of image appears faded. if there no transparency, good.
i saved 1 of images working png , created small bit of code duplicates problem. essentially, i'm creating new image transparent background , pasting image on top:
from pil import image img=image.new('rgba', (946,627), (0,0,0,0)) overlayimage = image.open('drawing.png') img.paste(overlayimage, (0,0), overlayimage) img.save('drawing-pasted.png') when completes, drawing-pasted.png looks this:

but original drawing (drawing.png) looked this:

(images cropped manually show detail.) original image circles fill color has alpha value of 179.
has else encountered this, , doing wrong?
thanks much.
the background creating black , transparent original blue alpha of 179 have 2 pixels (0,0,0,0) , (0,0,255,179) assuming 100% blue - since pasting image in over background use alpha of new image allowing (255-179)/255 or 30% black. (n.b. alpha of background makes no difference since behind new image)
you use overlayimage.putalpha set alpha 255 start image rather black background.
Comments
Post a Comment