mirror of
https://github.com/ocrmypdf/OCRmyPDF.git
synced 2025-12-28 07:30:04 +00:00
Use png256 raster device when possible
Someone reported a bug where the .png input to unpaper ended up being type 'P' (palette) for some reason, which was not supported in unpaper. Not sure how it happened, but seemed easier to fix by explicitly supporting. Here we use png256 if it would capture all colors in the input file. It's up to tesseract/reportlab to make use of the palette PNG when rendering.
This commit is contained in:
parent
3a445ad5f7
commit
83f9dfbac4
@ -475,10 +475,15 @@ def rasterize_with_ghostscript(
|
||||
if all(image['comp'] == 1 for image in pageinfo['images']):
|
||||
if all(image['bpc'] == 1 for image in pageinfo['images']):
|
||||
device = 'pngmono'
|
||||
elif not any(image['color'] == 'color'
|
||||
for image in pageinfo['images']):
|
||||
elif all(image['bpc'] > 1 and image['color'] == 'index'
|
||||
for image in pageinfo['images']):
|
||||
device = 'png256'
|
||||
elif all(image['bpc'] > 1 and image['color'] == 'gray'
|
||||
for image in pageinfo['images']):
|
||||
device = 'pnggray'
|
||||
|
||||
log.debug("Rendering {0} with {1}".format(
|
||||
os.path.basename(input_file), device))
|
||||
xres = max(pageinfo['xres'], options.oversample or 0)
|
||||
yres = max(pageinfo['yres'], options.oversample or 0)
|
||||
|
||||
|
||||
@ -34,6 +34,7 @@ FRIENDLY_COMP = {
|
||||
'rgb': 3,
|
||||
'cmyk': 4,
|
||||
'lab': 3,
|
||||
'index': 1
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user