Compare commits

..

No commits in common. "f59788708878e95224230274c8682b2cb7378008" and "29921eeabde1a2f9eb31f1383e5a820d9772c333" have entirely different histories.

2 changed files with 258 additions and 29 deletions

View file

@ -1322,10 +1322,6 @@ def get_imgmetadata(
if depth > 8: if depth > 8:
logger.warning("Image with transparency and a bit depth of %d." % depth) logger.warning("Image with transparency and a bit depth of %d." % depth)
logger.warning("This is unsupported due to PIL limitations.") logger.warning("This is unsupported due to PIL limitations.")
logger.warning(
"If you accept a lossy conversion, you can manually convert "
"your images to 8 bit using `convert -depth 8` from imagemagick"
)
raise AlphaChannelError( raise AlphaChannelError(
"Refusing to work with multiple >8bit channels." "Refusing to work with multiple >8bit channels."
) )
@ -1436,22 +1432,11 @@ def get_imgmetadata(
iccp = None iccp = None
if "icc_profile" in imgdata.info: if "icc_profile" in imgdata.info:
iccp = imgdata.info.get("icc_profile") iccp = imgdata.info.get("icc_profile")
# GIMP saves bilevel TIFF images and palette PNG images with only black and # GIMP saves bilevel tiff images with an RGB ICC profile which is useless
# white in the palette with an RGB ICC profile which is useless
# https://gitlab.gnome.org/GNOME/gimp/-/issues/3438
# and produces an error in Adobe Acrobat, so we ignore it with a warning. # and produces an error in Adobe Acrobat, so we ignore it with a warning.
# imagemagick also used to (wrongly) include an RGB ICC profile for bilevel # imagemagick also used to (wrongly) include an RGB ICC profile for bilevel
# images: https://github.com/ImageMagick/ImageMagick/issues/2070 # images: https://github.com/ImageMagick/ImageMagick/issues/2070
if iccp is not None and ( if iccp is not None and color == Colorspace["1"] and imgformat == ImageFormat.TIFF:
(color == Colorspace["1"] and imgformat == ImageFormat.TIFF)
or (
imgformat == ImageFormat.PNG
and color == Colorspace.P
and rawdata is not None
and parse_png(rawdata)[1]
in [b"\x00\x00\x00\xff\xff\xff", b"\xff\xff\xff\x00\x00\x00"]
)
):
with io.BytesIO(iccp) as f: with io.BytesIO(iccp) as f:
prf = ImageCms.ImageCmsProfile(f) prf = ImageCms.ImageCmsProfile(f)
if ( if (
@ -1459,14 +1444,7 @@ def get_imgmetadata(
and prf.profile.manufacturer == "GIMP" and prf.profile.manufacturer == "GIMP"
and prf.profile.profile_description == "GIMP built-in sRGB" and prf.profile.profile_description == "GIMP built-in sRGB"
): ):
if imgformat == ImageFormat.TIFF: logger.warning("Ignoring RGB ICC profile in bilevel TIFF produced by GIMP.")
logger.warning(
"Ignoring RGB ICC profile in bilevel TIFF produced by GIMP."
)
elif imgformat == ImageFormat.PNG:
logger.warning(
"Ignoring RGB ICC profile in 2-color palette PNG produced by GIMP."
)
logger.warning("https://gitlab.gnome.org/GNOME/gimp/-/issues/3438") logger.warning("https://gitlab.gnome.org/GNOME/gimp/-/issues/3438")
iccp = None iccp = None

View file

@ -24,6 +24,8 @@ import xml.etree.ElementTree as ET
img2pdfprog = os.getenv("img2pdfprog", default="src/img2pdf.py") img2pdfprog = os.getenv("img2pdfprog", default="src/img2pdf.py")
BYTEORDER = "LSB" if sys.byteorder == "little" else "MSB"
ICC_PROFILE = None ICC_PROFILE = None
ICC_PROFILE_PATHS = ( ICC_PROFILE_PATHS = (
# Debian # Debian
@ -2359,6 +2361,13 @@ def tiff_float_img(tmp_path_factory, tmp_normal_png):
}, str(identify) }, str(identify)
assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify)
assert identify[0]["image"].get("type") == "TrueColor", str(identify) assert identify[0]["image"].get("type") == "TrueColor", str(identify)
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("depth") == 8, str(identify) assert identify[0]["image"].get("depth") == 8, str(identify)
assert identify[0]["image"].get("baseDepth") == 32, str(identify) assert identify[0]["image"].get("baseDepth") == 32, str(identify)
assert identify[0]["image"].get("pageGeometry") == { assert identify[0]["image"].get("pageGeometry") == {
@ -2374,6 +2383,10 @@ def tiff_float_img(tmp_path_factory, tmp_normal_png):
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified" identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify) ), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB" identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB"
), str(identify) ), str(identify)
@ -2413,6 +2426,13 @@ def tiff_cmyk8_img(tmp_path_factory, tmp_normal_png):
}, str(identify) }, str(identify)
assert identify[0]["image"].get("colorspace") == "CMYK", str(identify) assert identify[0]["image"].get("colorspace") == "CMYK", str(identify)
assert identify[0]["image"].get("type") == "ColorSeparation", str(identify) assert identify[0]["image"].get("type") == "ColorSeparation", str(identify)
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("depth") == 8, str(identify) assert identify[0]["image"].get("depth") == 8, str(identify)
assert identify[0]["image"].get("pageGeometry") == { assert identify[0]["image"].get("pageGeometry") == {
"width": 60, "width": 60,
@ -2423,6 +2443,10 @@ def tiff_cmyk8_img(tmp_path_factory, tmp_normal_png):
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified" identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify) ), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") identify[0]["image"].get("properties", {}).get("tiff:photometric")
== "separated" == "separated"
@ -2465,6 +2489,13 @@ def tiff_cmyk16_img(tmp_path_factory, tmp_normal_png):
}, str(identify) }, str(identify)
assert identify[0]["image"].get("colorspace") == "CMYK", str(identify) assert identify[0]["image"].get("colorspace") == "CMYK", str(identify)
assert identify[0]["image"].get("type") == "ColorSeparation", str(identify) assert identify[0]["image"].get("type") == "ColorSeparation", str(identify)
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("depth") == 16, str(identify) assert identify[0]["image"].get("depth") == 16, str(identify)
assert identify[0]["image"].get("pageGeometry") == { assert identify[0]["image"].get("pageGeometry") == {
"width": 60, "width": 60,
@ -2475,6 +2506,10 @@ def tiff_cmyk16_img(tmp_path_factory, tmp_normal_png):
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified" identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify) ), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") identify[0]["image"].get("properties", {}).get("tiff:photometric")
== "separated" == "separated"
@ -2507,6 +2542,13 @@ def tiff_rgb8_img(tmp_path_factory, tmp_normal_png):
}, str(identify) }, str(identify)
assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify)
assert identify[0]["image"].get("type") == "TrueColor", str(identify) assert identify[0]["image"].get("type") == "TrueColor", str(identify)
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("depth") == 8, str(identify) assert identify[0]["image"].get("depth") == 8, str(identify)
assert identify[0]["image"].get("pageGeometry") == { assert identify[0]["image"].get("pageGeometry") == {
"width": 60, "width": 60,
@ -2517,6 +2559,10 @@ def tiff_rgb8_img(tmp_path_factory, tmp_normal_png):
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified" identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify) ), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB" identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB"
), str(identify) ), str(identify)
@ -2556,6 +2602,13 @@ def tiff_rgb12_img(tmp_path_factory, tmp_normal16_png):
}, str(identify) }, str(identify)
assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify)
assert identify[0]["image"].get("type") == "TrueColor", str(identify) assert identify[0]["image"].get("type") == "TrueColor", str(identify)
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("baseDepth") == 12, str(identify) assert identify[0]["image"].get("baseDepth") == 12, str(identify)
assert identify[0]["image"].get("pageGeometry") == { assert identify[0]["image"].get("pageGeometry") == {
"width": 60, "width": 60,
@ -2566,6 +2619,10 @@ def tiff_rgb12_img(tmp_path_factory, tmp_normal16_png):
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified" identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify) ), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB" identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB"
), str(identify) ), str(identify)
@ -2605,6 +2662,13 @@ def tiff_rgb14_img(tmp_path_factory, tmp_normal16_png):
}, str(identify) }, str(identify)
assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify)
assert identify[0]["image"].get("type") == "TrueColor", str(identify) assert identify[0]["image"].get("type") == "TrueColor", str(identify)
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("baseDepth") == 14, str(identify) assert identify[0]["image"].get("baseDepth") == 14, str(identify)
assert identify[0]["image"].get("pageGeometry") == { assert identify[0]["image"].get("pageGeometry") == {
"width": 60, "width": 60,
@ -2615,6 +2679,10 @@ def tiff_rgb14_img(tmp_path_factory, tmp_normal16_png):
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified" identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify) ), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB" identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB"
), str(identify) ), str(identify)
@ -2654,6 +2722,13 @@ def tiff_rgb16_img(tmp_path_factory, tmp_normal16_png):
}, str(identify) }, str(identify)
assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify)
assert identify[0]["image"].get("type") == "TrueColor", str(identify) assert identify[0]["image"].get("type") == "TrueColor", str(identify)
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("depth") == 16, str(identify) assert identify[0]["image"].get("depth") == 16, str(identify)
assert identify[0]["image"].get("pageGeometry") == { assert identify[0]["image"].get("pageGeometry") == {
"width": 60, "width": 60,
@ -2664,6 +2739,10 @@ def tiff_rgb16_img(tmp_path_factory, tmp_normal16_png):
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified" identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify) ), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB" identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB"
), str(identify) ), str(identify)
@ -2704,6 +2783,13 @@ def tiff_rgba8_img(tmp_path_factory, tmp_alpha_png):
}, str(identify) }, str(identify)
assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify)
assert identify[0]["image"].get("type") == "TrueColorAlpha", str(identify) assert identify[0]["image"].get("type") == "TrueColorAlpha", str(identify)
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("depth") == 8, str(identify) assert identify[0]["image"].get("depth") == 8, str(identify)
assert identify[0]["image"].get("pageGeometry") == { assert identify[0]["image"].get("pageGeometry") == {
"width": 60, "width": 60,
@ -2714,6 +2800,10 @@ def tiff_rgba8_img(tmp_path_factory, tmp_alpha_png):
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unassociated" identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unassociated"
), str(identify) ), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB" identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB"
), str(identify) ), str(identify)
@ -2754,6 +2844,13 @@ def tiff_rgba16_img(tmp_path_factory, tmp_alpha_png):
}, str(identify) }, str(identify)
assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify)
assert identify[0]["image"].get("type") == "TrueColorAlpha", str(identify) assert identify[0]["image"].get("type") == "TrueColorAlpha", str(identify)
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("depth") == 16, str(identify) assert identify[0]["image"].get("depth") == 16, str(identify)
assert identify[0]["image"].get("pageGeometry") == { assert identify[0]["image"].get("pageGeometry") == {
"width": 60, "width": 60,
@ -2764,6 +2861,10 @@ def tiff_rgba16_img(tmp_path_factory, tmp_alpha_png):
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unassociated" identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unassociated"
), str(identify) ), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB" identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB"
), str(identify) ), str(identify)
@ -2803,6 +2904,13 @@ def tiff_gray1_img(tmp_path_factory, tmp_gray1_png):
}, str(identify) }, str(identify)
assert identify[0]["image"].get("colorspace") == "Gray", str(identify) assert identify[0]["image"].get("colorspace") == "Gray", str(identify)
assert identify[0]["image"].get("type") == "Bilevel", str(identify) assert identify[0]["image"].get("type") == "Bilevel", str(identify)
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("depth") == 1, str(identify) assert identify[0]["image"].get("depth") == 1, str(identify)
assert identify[0]["image"].get("pageGeometry") == { assert identify[0]["image"].get("pageGeometry") == {
"width": 60, "width": 60,
@ -2813,6 +2921,10 @@ def tiff_gray1_img(tmp_path_factory, tmp_gray1_png):
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified" identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify) ), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") identify[0]["image"].get("properties", {}).get("tiff:photometric")
== "min-is-black" == "min-is-black"
@ -2853,6 +2965,13 @@ def tiff_gray2_img(tmp_path_factory, tmp_gray2_png):
}, str(identify) }, str(identify)
assert identify[0]["image"].get("colorspace") == "Gray", str(identify) assert identify[0]["image"].get("colorspace") == "Gray", str(identify)
assert identify[0]["image"].get("type") == "Grayscale", str(identify) assert identify[0]["image"].get("type") == "Grayscale", str(identify)
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("depth") == 2, str(identify) assert identify[0]["image"].get("depth") == 2, str(identify)
assert identify[0]["image"].get("pageGeometry") == { assert identify[0]["image"].get("pageGeometry") == {
"width": 60, "width": 60,
@ -2863,6 +2982,10 @@ def tiff_gray2_img(tmp_path_factory, tmp_gray2_png):
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified" identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify) ), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") identify[0]["image"].get("properties", {}).get("tiff:photometric")
== "min-is-black" == "min-is-black"
@ -2903,6 +3026,13 @@ def tiff_gray4_img(tmp_path_factory, tmp_gray4_png):
}, str(identify) }, str(identify)
assert identify[0]["image"].get("colorspace") == "Gray", str(identify) assert identify[0]["image"].get("colorspace") == "Gray", str(identify)
assert identify[0]["image"].get("type") == "Grayscale", str(identify) assert identify[0]["image"].get("type") == "Grayscale", str(identify)
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("depth") == 4, str(identify) assert identify[0]["image"].get("depth") == 4, str(identify)
assert identify[0]["image"].get("pageGeometry") == { assert identify[0]["image"].get("pageGeometry") == {
"width": 60, "width": 60,
@ -2913,6 +3043,10 @@ def tiff_gray4_img(tmp_path_factory, tmp_gray4_png):
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified" identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify) ), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") identify[0]["image"].get("properties", {}).get("tiff:photometric")
== "min-is-black" == "min-is-black"
@ -2953,6 +3087,13 @@ def tiff_gray8_img(tmp_path_factory, tmp_gray8_png):
}, str(identify) }, str(identify)
assert identify[0]["image"].get("colorspace") == "Gray", str(identify) assert identify[0]["image"].get("colorspace") == "Gray", str(identify)
assert identify[0]["image"].get("type") == "Grayscale", str(identify) assert identify[0]["image"].get("type") == "Grayscale", str(identify)
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("depth") == 8, str(identify) assert identify[0]["image"].get("depth") == 8, str(identify)
assert identify[0]["image"].get("pageGeometry") == { assert identify[0]["image"].get("pageGeometry") == {
"width": 60, "width": 60,
@ -2963,6 +3104,10 @@ def tiff_gray8_img(tmp_path_factory, tmp_gray8_png):
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified" identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify) ), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") identify[0]["image"].get("properties", {}).get("tiff:photometric")
== "min-is-black" == "min-is-black"
@ -3003,6 +3148,13 @@ def tiff_gray16_img(tmp_path_factory, tmp_gray16_png):
}, str(identify) }, str(identify)
assert identify[0]["image"].get("colorspace") == "Gray", str(identify) assert identify[0]["image"].get("colorspace") == "Gray", str(identify)
assert identify[0]["image"].get("type") == "Grayscale", str(identify) assert identify[0]["image"].get("type") == "Grayscale", str(identify)
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("depth") == 16, str(identify) assert identify[0]["image"].get("depth") == 16, str(identify)
assert identify[0]["image"].get("pageGeometry") == { assert identify[0]["image"].get("pageGeometry") == {
"width": 60, "width": 60,
@ -3013,6 +3165,10 @@ def tiff_gray16_img(tmp_path_factory, tmp_gray16_png):
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified" identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify) ), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") identify[0]["image"].get("properties", {}).get("tiff:photometric")
== "min-is-black" == "min-is-black"
@ -3055,6 +3211,13 @@ def tiff_multipage_img(tmp_path_factory, tmp_normal_png, tmp_inverse_png):
}, str(identify) }, str(identify)
assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify)
assert identify[0]["image"].get("type") == "TrueColor", str(identify) assert identify[0]["image"].get("type") == "TrueColor", str(identify)
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("depth") == 8, str(identify) assert identify[0]["image"].get("depth") == 8, str(identify)
assert identify[0]["image"].get("pageGeometry") == { assert identify[0]["image"].get("pageGeometry") == {
"width": 60, "width": 60,
@ -3065,6 +3228,10 @@ def tiff_multipage_img(tmp_path_factory, tmp_normal_png, tmp_inverse_png):
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified" identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify) ), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB" identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB"
), str(identify) ), str(identify)
@ -3088,6 +3255,13 @@ def tiff_multipage_img(tmp_path_factory, tmp_normal_png, tmp_inverse_png):
}, str(identify) }, str(identify)
assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify)
assert identify[0]["image"].get("type") == "TrueColor", str(identify) assert identify[0]["image"].get("type") == "TrueColor", str(identify)
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("depth") == 8, str(identify) assert identify[0]["image"].get("depth") == 8, str(identify)
assert identify[0]["image"].get("pageGeometry") == { assert identify[0]["image"].get("pageGeometry") == {
"width": 60, "width": 60,
@ -3098,6 +3272,10 @@ def tiff_multipage_img(tmp_path_factory, tmp_normal_png, tmp_inverse_png):
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified" identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify) ), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB" identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB"
), str(identify) ), str(identify)
@ -3130,6 +3308,13 @@ def tiff_palette1_img(tmp_path_factory, tmp_palette1_png):
}, str(identify) }, str(identify)
assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify)
assert identify[0]["image"].get("type") == "Palette", str(identify) assert identify[0]["image"].get("type") == "Palette", str(identify)
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("depth") == 8, str(identify) assert identify[0]["image"].get("depth") == 8, str(identify)
assert identify[0]["image"].get("baseDepth") == 1, str(identify) assert identify[0]["image"].get("baseDepth") == 1, str(identify)
assert identify[0]["image"].get("colormapEntries") == 2, str(identify) assert identify[0]["image"].get("colormapEntries") == 2, str(identify)
@ -3142,6 +3327,10 @@ def tiff_palette1_img(tmp_path_factory, tmp_palette1_png):
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified" identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify) ), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "palette" identify[0]["image"].get("properties", {}).get("tiff:photometric") == "palette"
), str(identify) ), str(identify)
@ -3173,6 +3362,13 @@ def tiff_palette2_img(tmp_path_factory, tmp_palette2_png):
}, str(identify) }, str(identify)
assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify)
assert identify[0]["image"].get("type") == "Palette", str(identify) assert identify[0]["image"].get("type") == "Palette", str(identify)
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("depth") == 8, str(identify) assert identify[0]["image"].get("depth") == 8, str(identify)
assert identify[0]["image"].get("baseDepth") == 2, str(identify) assert identify[0]["image"].get("baseDepth") == 2, str(identify)
assert identify[0]["image"].get("colormapEntries") == 4, str(identify) assert identify[0]["image"].get("colormapEntries") == 4, str(identify)
@ -3185,6 +3381,10 @@ def tiff_palette2_img(tmp_path_factory, tmp_palette2_png):
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified" identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify) ), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "palette" identify[0]["image"].get("properties", {}).get("tiff:photometric") == "palette"
), str(identify) ), str(identify)
@ -3216,6 +3416,13 @@ def tiff_palette4_img(tmp_path_factory, tmp_palette4_png):
}, str(identify) }, str(identify)
assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify)
assert identify[0]["image"].get("type") == "Palette", str(identify) assert identify[0]["image"].get("type") == "Palette", str(identify)
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("depth") == 8, str(identify) assert identify[0]["image"].get("depth") == 8, str(identify)
assert identify[0]["image"].get("baseDepth") == 4, str(identify) assert identify[0]["image"].get("baseDepth") == 4, str(identify)
assert identify[0]["image"].get("colormapEntries") == 16, str(identify) assert identify[0]["image"].get("colormapEntries") == 16, str(identify)
@ -3228,6 +3435,10 @@ def tiff_palette4_img(tmp_path_factory, tmp_palette4_png):
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified" identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify) ), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "palette" identify[0]["image"].get("properties", {}).get("tiff:photometric") == "palette"
), str(identify) ), str(identify)
@ -3259,6 +3470,13 @@ def tiff_palette8_img(tmp_path_factory, tmp_palette8_png):
}, str(identify) }, str(identify)
assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify)
assert identify[0]["image"].get("type") == "Palette", str(identify) assert identify[0]["image"].get("type") == "Palette", str(identify)
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("depth") == 8, str(identify) assert identify[0]["image"].get("depth") == 8, str(identify)
assert identify[0]["image"].get("colormapEntries") == 256, str(identify) assert identify[0]["image"].get("colormapEntries") == 256, str(identify)
assert identify[0]["image"].get("pageGeometry") == { assert identify[0]["image"].get("pageGeometry") == {
@ -3270,6 +3488,10 @@ def tiff_palette8_img(tmp_path_factory, tmp_palette8_png):
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified" identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify) ), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert ( assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "palette" identify[0]["image"].get("properties", {}).get("tiff:photometric") == "palette"
), str(identify) ), str(identify)
@ -3319,7 +3541,9 @@ def tiff_ccitt_lsb_m2l_white_img(tmp_path_factory, tmp_gray1_png):
assert identify[0]["image"].get(endian) in [ assert identify[0]["image"].get(endian) in [
"Undefined", "Undefined",
"LSB", "LSB",
], str(identify) ], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("depth") == 1, str(identify) assert identify[0]["image"].get("depth") == 1, str(identify)
assert identify[0]["image"].get("pageGeometry") == { assert identify[0]["image"].get("pageGeometry") == {
"width": 60, "width": 60,
@ -3570,7 +3794,9 @@ def tiff_ccitt_lsb_m2l_black_img(tmp_path_factory, tmp_gray1_png):
assert identify[0]["image"].get(endian) in [ assert identify[0]["image"].get(endian) in [
"Undefined", "Undefined",
"LSB", "LSB",
], str(identify) ], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("depth") == 1, str(identify) assert identify[0]["image"].get("depth") == 1, str(identify)
assert identify[0]["image"].get("pageGeometry") == { assert identify[0]["image"].get("pageGeometry") == {
"width": 60, "width": 60,
@ -3661,7 +3887,9 @@ def tiff_ccitt_nometa1_img(tmp_path_factory, tmp_gray1_png):
assert identify[0]["image"].get(endian) in [ assert identify[0]["image"].get(endian) in [
"Undefined", "Undefined",
"LSB", "LSB",
], str(identify) ], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("depth") == 1, str(identify) assert identify[0]["image"].get("depth") == 1, str(identify)
assert identify[0]["image"].get("pageGeometry") == { assert identify[0]["image"].get("pageGeometry") == {
"width": 60, "width": 60,
@ -3746,7 +3974,9 @@ def tiff_ccitt_nometa2_img(tmp_path_factory, tmp_gray1_png):
assert identify[0]["image"].get(endian) in [ assert identify[0]["image"].get(endian) in [
"Undefined", "Undefined",
"LSB", "LSB",
], str(identify) ], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("colorspace") == "Gray", str(identify) assert identify[0]["image"].get("colorspace") == "Gray", str(identify)
assert identify[0]["image"].get("depth") == 1, str(identify) assert identify[0]["image"].get("depth") == 1, str(identify)
assert identify[0]["image"].get("compression") == "Group4", str(identify) assert identify[0]["image"].get("compression") == "Group4", str(identify)
@ -3812,6 +4042,13 @@ def miff_cmyk8_img(tmp_path_factory, tmp_normal_png):
}, str(identify) }, str(identify)
assert identify[0]["image"].get("colorspace") == "CMYK", str(identify) assert identify[0]["image"].get("colorspace") == "CMYK", str(identify)
assert identify[0]["image"].get("type") == "ColorSeparation", str(identify) assert identify[0]["image"].get("type") == "ColorSeparation", str(identify)
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("depth") == 8, str(identify) assert identify[0]["image"].get("depth") == 8, str(identify)
assert identify[0]["image"].get("pageGeometry") == { assert identify[0]["image"].get("pageGeometry") == {
"width": 60, "width": 60,
@ -3856,6 +4093,13 @@ def miff_cmyk16_img(tmp_path_factory, tmp_normal_png):
}, str(identify) }, str(identify)
assert identify[0]["image"].get("colorspace") == "CMYK", str(identify) assert identify[0]["image"].get("colorspace") == "CMYK", str(identify)
assert identify[0]["image"].get("type") == "ColorSeparation", str(identify) assert identify[0]["image"].get("type") == "ColorSeparation", str(identify)
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("depth") == 16, str(identify) assert identify[0]["image"].get("depth") == 16, str(identify)
assert identify[0]["image"].get("baseDepth") == 16, str(identify) assert identify[0]["image"].get("baseDepth") == 16, str(identify)
assert identify[0]["image"].get("pageGeometry") == { assert identify[0]["image"].get("pageGeometry") == {
@ -3891,6 +4135,13 @@ def miff_rgb8_img(tmp_path_factory, tmp_normal_png):
}, str(identify) }, str(identify)
assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify)
assert identify[0]["image"].get("type") == "TrueColor", str(identify) assert identify[0]["image"].get("type") == "TrueColor", str(identify)
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
assert identify[0]["image"].get("depth") == 8, str(identify) assert identify[0]["image"].get("depth") == 8, str(identify)
assert identify[0]["image"].get("pageGeometry") == { assert identify[0]["image"].get("pageGeometry") == {
"width": 60, "width": 60,