We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If you try to use alpha_composite with a negative dest, it produces an error message. For example:
alpha_composite
from PIL import Image solid_green = Image.new("RGBA",(100,100),(0,255,0,255)) semidark = Image.new("RGBA",(100,100),(0,0,0,127)) ac_result = solid_green.copy() ac_result.alpha_composite(semidark,(-50,50)) ac_result.show() # => ValueError: Destination must be non-negative
Contrast this with paste, which allows negative destinations:
paste,
from PIL import Image solid_green = Image.new("RGBA",(100,100),(0,255,0,255)) semidark = Image.new("RGBA",(100,100),(0,0,0,127)) paste_result = solid_green.copy() paste_result.paste(semidark,(-50,50),semidark) paste_result.show() # Works but colors aren't alpha composited
Negatives do indicate clipping on the left or top but note that alpha_composite (like paste) already allows clipping on the right and bottom.
paste
from PIL import Image solid_green = Image.new("RGBA",(100,100),(0,255,0,255)) semidark = Image.new("RGBA",(100,100),(0,0,0,127)) ac_result = solid_green.copy() ac_result.alpha_composite(semidark,(50,50)) ac_result.show() # Works great!
Until this issue is addressed, here is a work around:
def alpha_composite_workaround(image0, image1, dest): x1,y1 = dest if x1 >= 0 and y1 >= 0: image0.alpha_composite(image1, dest=(x1, y1)) else: temp = Image.new("RGBA", image0.size, (0, 0, 0, 0)) temp.paste(image1, (x1, y1)) image0.alpha_composite(temp) from PIL import Image solid_green = Image.new("RGBA",(100,100),(0,255,0,255)) semidark = Image.new("RGBA",(100,100),(0,0,0,127)) ac_result = solid_green.copy() alpha_composite_workaround(ac_result,semidark,(-50,50)) ac_result.show()
The text was updated successfully, but these errors were encountered:
alpha_composite was added in #2595 by @wiredfool. Did he have any thoughts on this?
Sorry, something went wrong.
I've created #5313 to resolve this.
Successfully merging a pull request may close this issue.
If you try to use
alpha_composite
with a negative dest, it produces an error message. For example:Contrast this with
paste,
which allows negative destinations:Negatives do indicate clipping on the left or top but note that
alpha_composite
(likepaste
) already allows clipping on the right and bottom.Until this issue is addressed, here is a work around:
The text was updated successfully, but these errors were encountered: