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
|
@ -22,7 +22,8 @@ import zipfile
|
||||||
import dlsite_async
|
import dlsite_async
|
||||||
import fitz
|
import fitz
|
||||||
from libsixel import *
|
from libsixel import *
|
||||||
from PIL import Image
|
from PIL import Image, UnidentifiedImageError
|
||||||
|
import PIL.ImageFile
|
||||||
from jinja2 import Environment, PackageLoader, select_autoescape
|
from jinja2 import Environment, PackageLoader, select_autoescape
|
||||||
import pyuca
|
import pyuca
|
||||||
import rarfile
|
import rarfile
|
||||||
|
@ -918,8 +919,17 @@ def descendant_files_ignore(path, exclude):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def standalone_image_size(filepath):
|
def standalone_image_size(filepath):
|
||||||
|
try:
|
||||||
with Image.open(filepath) as im:
|
with Image.open(filepath) as im:
|
||||||
return im.size
|
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):
|
def pdf_image_sizes(filepath):
|
||||||
sizes_by_xref = {}
|
sizes_by_xref = {}
|
||||||
|
|
Loading…
Reference in a new issue