mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-31 07:57:27 +03:00 
			
		
		
		
	Consider transparency when applying blend mask
This commit is contained in:
		
							parent
							
								
									2d5f451f58
								
							
						
					
					
						commit
						0966293a0d
					
				
							
								
								
									
										
											BIN
										
									
								
								Tests/images/blend_transparency.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Tests/images/blend_transparency.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 211 B | 
|  | @ -163,6 +163,12 @@ def test_apng_blend(): | |||
|         assert im.getpixel((64, 32)) == (0, 255, 0, 255) | ||||
| 
 | ||||
| 
 | ||||
| def test_apng_blend_transparency(): | ||||
|     with Image.open("Tests/images/blend_transparency.png") as im: | ||||
|         im.seek(1) | ||||
|         assert im.getpixel((0, 0)) == (255, 0, 0) | ||||
| 
 | ||||
| 
 | ||||
| def test_apng_chunk_order(): | ||||
|     with Image.open("Tests/images/apng/fctl_actl.png") as im: | ||||
|         im.seek(im.n_frames - 1) | ||||
|  |  | |||
|  | @ -1003,9 +1003,13 @@ class PngImageFile(ImageFile.ImageFile): | |||
|         else: | ||||
|             if self._prev_im and self.blend_op == Blend.OP_OVER: | ||||
|                 updated = self._crop(self.im, self.dispose_extent) | ||||
|                 self._prev_im.paste( | ||||
|                     updated, self.dispose_extent, updated.convert("RGBA") | ||||
|                 ) | ||||
|                 if self.im.mode == "RGB" and "transparency" in self.info: | ||||
|                     mask = updated.convert_transparent( | ||||
|                         "RGBA", self.info["transparency"] | ||||
|                     ) | ||||
|                 else: | ||||
|                     mask = updated.convert("RGBA") | ||||
|                 self._prev_im.paste(updated, self.dispose_extent, mask) | ||||
|                 self.im = self._prev_im | ||||
|                 if self.pyaccess: | ||||
|                     self.pyaccess = None | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user