accept PNGs that have broken CRC32 checksums for ancillary chunks, which is apparently a thing we need to deal with???
This commit is contained in:
		
							parent
							
								
									21c6e11228
								
							
						
					
					
						commit
						987f427c56
					
				
					 1 changed files with 13 additions and 3 deletions
				
			
		|  | @ -22,7 +22,8 @@ import zipfile | |||
| import dlsite_async | ||||
| import fitz | ||||
| from libsixel import * | ||||
| from PIL import Image | ||||
| from PIL import Image, UnidentifiedImageError | ||||
| import PIL.ImageFile | ||||
| from jinja2 import Environment, PackageLoader, select_autoescape | ||||
| import pyuca | ||||
| import rarfile | ||||
|  | @ -918,8 +919,17 @@ def descendant_files_ignore(path, exclude): | |||
|     return result | ||||
| 
 | ||||
| def standalone_image_size(filepath): | ||||
|     try: | ||||
|         with Image.open(filepath) as im: | ||||
|             return im.size | ||||
|     except UnidentifiedImageError: | ||||
|         print(f'Warning: PIL failed to load image {filepath}! Retrying with less strict settings') | ||||
|         PIL.ImageFile.LOAD_TRUNCATED_IMAGES = True | ||||
|         try: | ||||
|             with Image.open(filepath) as im: | ||||
|                 return im.size | ||||
|         finally: | ||||
|             PIL.ImageFile.LOAD_TRUNCATED_IMAGES = False | ||||
| 
 | ||||
| def pdf_image_sizes(filepath): | ||||
|     sizes_by_xref = {} | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue