Skip to content

Commit

Permalink
recode: strip transparency from images in MRC
Browse files Browse the repository at this point in the history
I don't think we have a way to support transparency in the PDF anyway,
as we already overlay images with a mask, so just strip the
transparency.

Alternatively we could hide this behind an option flag and error unless
the flag --flatten-transparent-images (or so) is passed.

Resolves issue #45 ( #45 )
  • Loading branch information
MerlijnWajer committed May 7, 2022
1 parent 9bf3ef4 commit e1f2b11
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internetarchivepdf/recode.py
Expand Up @@ -346,6 +346,12 @@ def insert_images_mrc(to_pdf, hocr_file, from_pdf=None, image_files=None,
image = Image.open(imgfile)
image.load()

if image.mode in ('RGBA', 'LA'):
if image.mode == 'RGBA':
image = image.convert('RGB')
else image.mode == 'LA':
image = image.convert('L')

if timing_data is not None:
timing_data.append(('image_load', time()-t))

Expand Down

0 comments on commit e1f2b11

Please sign in to comment.