mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 01:47:47 +03:00 
			
		
		
		
	Merge pull request #6779 from radarhere/gif_duration
Resolves https://github.com/python-pillow/Pillow/issues/6778
This commit is contained in:
		
						commit
						d013fbf656
					
				
							
								
								
									
										
											BIN
										
									
								
								Tests/images/duplicate_frame.gif
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Tests/images/duplicate_frame.gif
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 138 B  | 
| 
						 | 
					@ -791,6 +791,22 @@ def test_roundtrip_info_duration(tmp_path):
 | 
				
			||||||
        ] == duration_list
 | 
					        ] == duration_list
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def test_roundtrip_info_duration_combined(tmp_path):
 | 
				
			||||||
 | 
					    out = str(tmp_path / "temp.gif")
 | 
				
			||||||
 | 
					    with Image.open("Tests/images/duplicate_frame.gif") as im:
 | 
				
			||||||
 | 
					        assert [frame.info["duration"] for frame in ImageSequence.Iterator(im)] == [
 | 
				
			||||||
 | 
					            1000,
 | 
				
			||||||
 | 
					            1000,
 | 
				
			||||||
 | 
					            1000,
 | 
				
			||||||
 | 
					        ]
 | 
				
			||||||
 | 
					        im.save(out, save_all=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    with Image.open(out) as reloaded:
 | 
				
			||||||
 | 
					        assert [
 | 
				
			||||||
 | 
					            frame.info["duration"] for frame in ImageSequence.Iterator(reloaded)
 | 
				
			||||||
 | 
					        ] == [1000, 2000]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_identical_frames(tmp_path):
 | 
					def test_identical_frames(tmp_path):
 | 
				
			||||||
    duration_list = [1000, 1500, 2000, 4000]
 | 
					    duration_list = [1000, 1500, 2000, 4000]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -618,7 +618,7 @@ def _write_multiple_frames(im, fp, palette):
 | 
				
			||||||
                bbox = delta.getbbox()
 | 
					                bbox = delta.getbbox()
 | 
				
			||||||
                if not bbox:
 | 
					                if not bbox:
 | 
				
			||||||
                    # This frame is identical to the previous frame
 | 
					                    # This frame is identical to the previous frame
 | 
				
			||||||
                    if duration:
 | 
					                    if encoderinfo.get("duration"):
 | 
				
			||||||
                        previous["encoderinfo"]["duration"] += encoderinfo["duration"]
 | 
					                        previous["encoderinfo"]["duration"] += encoderinfo["duration"]
 | 
				
			||||||
                    continue
 | 
					                    continue
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user