mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-31 07:57:27 +03:00 
			
		
		
		
	Merge pull request #5609 from thak1411/round-error
Fixed error saving APNG with duplicate frames and different duration times
This commit is contained in:
		
						commit
						1fd0411ee4
					
				|  | @ -433,7 +433,9 @@ def test_apng_save_duration_loop(tmp_path): | ||||||
| 
 | 
 | ||||||
|     # test removal of duplicated frames |     # test removal of duplicated frames | ||||||
|     frame = Image.new("RGBA", (128, 64), (255, 0, 0, 255)) |     frame = Image.new("RGBA", (128, 64), (255, 0, 0, 255)) | ||||||
|     frame.save(test_file, save_all=True, append_images=[frame], duration=[500, 250]) |     frame.save( | ||||||
|  |         test_file, save_all=True, append_images=[frame, frame], duration=[500, 100, 150] | ||||||
|  |     ) | ||||||
|     with Image.open(test_file) as im: |     with Image.open(test_file) as im: | ||||||
|         im.load() |         im.load() | ||||||
|         assert im.n_frames == 1 |         assert im.n_frames == 1 | ||||||
|  |  | ||||||
|  | @ -1117,12 +1117,12 @@ def _write_multiple_frames(im, fp, chunk, rawmode): | ||||||
|                     and prev_disposal == encoderinfo.get("disposal") |                     and prev_disposal == encoderinfo.get("disposal") | ||||||
|                     and prev_blend == encoderinfo.get("blend") |                     and prev_blend == encoderinfo.get("blend") | ||||||
|                 ): |                 ): | ||||||
|                     duration = encoderinfo.get("duration", 0) |                     frame_duration = encoderinfo.get("duration", 0) | ||||||
|                     if duration: |                     if frame_duration: | ||||||
|                         if "duration" in previous["encoderinfo"]: |                         if "duration" in previous["encoderinfo"]: | ||||||
|                             previous["encoderinfo"]["duration"] += duration |                             previous["encoderinfo"]["duration"] += frame_duration | ||||||
|                         else: |                         else: | ||||||
|                             previous["encoderinfo"]["duration"] = duration |                             previous["encoderinfo"]["duration"] = frame_duration | ||||||
|                     continue |                     continue | ||||||
|             else: |             else: | ||||||
|                 bbox = None |                 bbox = None | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user