mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-30 15:37:55 +03:00 
			
		
		
		
	- Fix incorrect pixel width in WebP RGBX import call
- Add a test to cover RGBX import
This commit is contained in:
		
							parent
							
								
									b3e90a37e9
								
							
						
					
					
						commit
						405d1a64d8
					
				|  | @ -33,7 +33,7 @@ class TestFileWebpAnimation(PillowTestCase): | |||
|         self.assertEqual(im.n_frames, 42) | ||||
|         self.assertTrue(im.is_animated) | ||||
| 
 | ||||
|     def test_write_animation(self): | ||||
|     def test_write_animation_L(self): | ||||
|         """ | ||||
|         Convert an animated GIF to animated WebP, then compare the | ||||
|         frame count, and first and last frames to ensure they're | ||||
|  | @ -58,6 +58,33 @@ class TestFileWebpAnimation(PillowTestCase): | |||
|         im.load() | ||||
|         self.assert_image_similar(im, orig.convert("RGBA"), 25.0) | ||||
| 
 | ||||
|     def test_write_animation_RGB(self): | ||||
|         """ | ||||
|         Write an animated WebP from RGB frames, and ensure the frames | ||||
|         are visually similar to the originals. | ||||
|         """ | ||||
| 
 | ||||
|         temp_file = self.tempfile("temp.webp") | ||||
|         temp_file2 = self.tempfile("temp.png") | ||||
|         frame1 = Image.open('Tests/images/anim_frame1.webp') | ||||
|         frame2 = Image.open('Tests/images/anim_frame2.webp') | ||||
|         frame1.save(temp_file, save_all=True, append_images=[frame2], lossless=True) | ||||
| 
 | ||||
|         im = Image.open(temp_file) | ||||
|         self.assertEqual(im.n_frames, 2) | ||||
|         print("Test File: " + temp_file) | ||||
| 
 | ||||
|         # Compare first frame to original | ||||
|         im.load() | ||||
|         im.save(temp_file2) | ||||
|         print("Frame 1: " + temp_file2) | ||||
|         self.assert_image_equal(im, frame1.convert("RGBA")) | ||||
| 
 | ||||
|         # Compare second frame to original | ||||
|         im.seek(1) | ||||
|         im.load() | ||||
|         self.assert_image_equal(im, frame2.convert("RGBA")) | ||||
| 
 | ||||
|     def test_timestamp_and_duration(self): | ||||
|         """ | ||||
|         Try passing a list of durations, and make sure the encoded | ||||
|  |  | |||
							
								
								
									
										2
									
								
								_webp.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								_webp.c
									
									
									
									
									
								
							|  | @ -205,7 +205,7 @@ PyObject* _anim_encoder_add(PyObject* self, PyObject* args) | |||
|     if (strcmp(mode, "RGBA")==0) { | ||||
|         WebPPictureImportRGBA(frame, rgb, 4 * width); | ||||
|     } else if (strcmp(mode, "RGBX")==0) { | ||||
|         WebPPictureImportRGBX(frame, rgb, 3 * width); | ||||
|         WebPPictureImportRGBX(frame, rgb, 4 * width); | ||||
|     } | ||||
| 
 | ||||
|     // Add the frame to the encoder
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user