instead of storing a limited list of supported colorspaces and imageformats, store the items requiring special treatment but do not abort if a value other than the listed ones is supported by PIL
This commit is contained in:
parent
00c73a6691
commit
ef9eac7326
1 changed files with 5 additions and 5 deletions
|
@ -56,9 +56,9 @@ FitMode = Enum('FitMode', 'into fill exact shrink enlarge')
|
||||||
|
|
||||||
PageOrientation = Enum('PageOrientation', 'portrait landscape')
|
PageOrientation = Enum('PageOrientation', 'portrait landscape')
|
||||||
|
|
||||||
Colorspace = Enum('Colorspace', 'RGB L 1 CMYK CMYK;I RGBA P')
|
Colorspace = Enum('Colorspace', 'RGB L 1 CMYK CMYK;I RGBA P other')
|
||||||
|
|
||||||
ImageFormat = Enum('ImageFormat', 'JPEG JPEG2000 TIFF PNG GIF')
|
ImageFormat = Enum('ImageFormat', 'JPEG JPEG2000 other')
|
||||||
|
|
||||||
PageMode = Enum('PageMode', 'none outlines thumbs')
|
PageMode = Enum('PageMode', 'none outlines thumbs')
|
||||||
|
|
||||||
|
@ -570,7 +570,7 @@ def get_imgmetadata(imgdata, imgformat, default_dpi, colorspace, rawdata=None):
|
||||||
if c.name == ics:
|
if c.name == ics:
|
||||||
color = c
|
color = c
|
||||||
if color is None:
|
if color is None:
|
||||||
raise ValueError("unknown PIL colorspace: %s" % imgdata.mode)
|
color = Colorspace.other
|
||||||
if color == Colorspace.CMYK and imgformat == ImageFormat.JPEG:
|
if color == Colorspace.CMYK and imgformat == ImageFormat.JPEG:
|
||||||
# Adobe inverts CMYK JPEGs for some reason, and others
|
# Adobe inverts CMYK JPEGs for some reason, and others
|
||||||
# have followed suit as well. Some software assumes the
|
# have followed suit as well. Some software assumes the
|
||||||
|
@ -606,7 +606,7 @@ def read_images(rawdata, colorspace, first_frame_only=False):
|
||||||
if f.name == imgdata.format:
|
if f.name == imgdata.format:
|
||||||
imgformat = f
|
imgformat = f
|
||||||
if imgformat is None:
|
if imgformat is None:
|
||||||
raise ValueError("unknown PIL image format: %s" % imgdata.format)
|
imgformat = ImageFormat.other
|
||||||
|
|
||||||
logging.debug("imgformat = %s", imgformat.name)
|
logging.debug("imgformat = %s", imgformat.name)
|
||||||
|
|
||||||
|
@ -650,7 +650,7 @@ def read_images(rawdata, colorspace, first_frame_only=False):
|
||||||
Colorspace["CMYK;I"]]:
|
Colorspace["CMYK;I"]]:
|
||||||
logging.debug("Colorspace is OK: %s", color)
|
logging.debug("Colorspace is OK: %s", color)
|
||||||
newimg = imgdata
|
newimg = imgdata
|
||||||
elif color in [Colorspace.RGBA, Colorspace.P]:
|
elif color in [Colorspace.RGBA, Colorspace.P, Colorspace.other]:
|
||||||
logging.debug("Converting colorspace %s to RGB", color)
|
logging.debug("Converting colorspace %s to RGB", color)
|
||||||
newimg = imgdata.convert('RGB')
|
newimg = imgdata.convert('RGB')
|
||||||
color = Colorspace.RGB
|
color = Colorspace.RGB
|
||||||
|
|
Loading…
Reference in a new issue