|
|
@ -1318,10 +1318,16 @@ def get_imgmetadata(
|
|
|
|
INCH_PER_METER = 39.370079
|
|
|
|
INCH_PER_METER = 39.370079
|
|
|
|
if xres == 0:
|
|
|
|
if xres == 0:
|
|
|
|
hdpi = default_dpi
|
|
|
|
hdpi = default_dpi
|
|
|
|
|
|
|
|
elif xres < 1000:
|
|
|
|
|
|
|
|
# If xres is very small, it's likely accidentally expressed in dpi instead
|
|
|
|
|
|
|
|
# of dpm. See e.g. https://github.com/agl/jbig2enc/issues/86
|
|
|
|
|
|
|
|
hdpi = xres
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
hdpi = int(float(xres) / INCH_PER_METER)
|
|
|
|
hdpi = int(float(xres) / INCH_PER_METER)
|
|
|
|
if yres == 0:
|
|
|
|
if yres == 0:
|
|
|
|
vdpi = default_dpi
|
|
|
|
vdpi = default_dpi
|
|
|
|
|
|
|
|
elif yres < 1000:
|
|
|
|
|
|
|
|
vdpi = yres
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
vdpi = int(float(yres) / INCH_PER_METER)
|
|
|
|
vdpi = int(float(yres) / INCH_PER_METER)
|
|
|
|
ndpi = (hdpi, vdpi)
|
|
|
|
ndpi = (hdpi, vdpi)
|
|
|
@ -1840,9 +1846,8 @@ def read_images(
|
|
|
|
# For now we only support single-page generic coding of JBIG2, for example as generated by
|
|
|
|
# For now we only support single-page generic coding of JBIG2, for example as generated by
|
|
|
|
# https://github.com/agl/jbig2enc
|
|
|
|
# https://github.com/agl/jbig2enc
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# In fact, you can pipe an example image like 042.bmp from https://git.ghostscript.com/?p=tests.git;a=blob_plain;f=jbig2/042.bmp;hb=HEAD
|
|
|
|
# In fact, you can pipe an example image `like src/tests/input/mono.png` directly into img2pdf:
|
|
|
|
# directly into img2pdf:
|
|
|
|
# jbig2 src/tests/input/mono.png | img2pdf -o src/tests/output/mono.png.pdf
|
|
|
|
# jbig2 042.bmp | img2pdf > 042.pdf
|
|
|
|
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# For this we assume that the first 13 bytes are the JBIG file header describing a document with one page,
|
|
|
|
# For this we assume that the first 13 bytes are the JBIG file header describing a document with one page,
|
|
|
|
# followed by a "page information" segment describing the dimensions of that page.
|
|
|
|
# followed by a "page information" segment describing the dimensions of that page.
|
|
|
@ -1854,11 +1859,11 @@ def read_images(
|
|
|
|
# \_____________________/ | \_________/ \______
|
|
|
|
# \_____________________/ | \_________/ \______
|
|
|
|
# magic-bytes org/unk pages seg-num
|
|
|
|
# magic-bytes org/unk pages seg-num
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# 00 30 00 01 00 00 00 13 || 00 00 06 c0 00 00 09 23
|
|
|
|
# 00 30 00 01 00 00 00 13 || 00 00 00 73 00 00 00 30
|
|
|
|
# _/ | | | \_________/ || \_________/ \_________/
|
|
|
|
# _/ | | | \_________/ || \_________/ \_________/
|
|
|
|
# type refs page seg-size || width-px height-px
|
|
|
|
# type refs page seg-size || width-px height-px
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# 00 00 00 00 00 00 00 00
|
|
|
|
# 00 00 00 48 00 00 00 48
|
|
|
|
# \_________/ \_________/
|
|
|
|
# \_________/ \_________/
|
|
|
|
# xres yres
|
|
|
|
# xres yres
|
|
|
|
#
|
|
|
|
#
|
|
|
|