From 585e0ba76687ae2872faed88bd1edc5b051136ca Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 25 Jun 2020 17:23:06 -0700 Subject: poppler: correct RGBA buffer endian-ness --- python/sandcrawler/pdfextract.py | 2 +- python/scripts/pdf_thumbnail.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python/sandcrawler/pdfextract.py b/python/sandcrawler/pdfextract.py index 4606632..6a78a0a 100644 --- a/python/sandcrawler/pdfextract.py +++ b/python/sandcrawler/pdfextract.py @@ -158,7 +158,7 @@ def process_pdf(blob: bytes, thumb_size=(180,300), thumb_type="JPEG") -> PdfExtr renderer = poppler.PageRenderer() try: full_img = renderer.render_page(page0) - img = Image.frombuffer("RGBA", (full_img.width, full_img.height), full_img.data, 'raw', "RGBA", 0, 1) + img = Image.frombuffer("RGBA", (full_img.width, full_img.height), full_img.data, 'raw', "BGRA", 0, 1) img.thumbnail(thumb_size, Image.BICUBIC) buf = BytesIO() img.save(buf, thumb_type) diff --git a/python/scripts/pdf_thumbnail.py b/python/scripts/pdf_thumbnail.py index e093dc3..af08db6 100755 --- a/python/scripts/pdf_thumbnail.py +++ b/python/scripts/pdf_thumbnail.py @@ -22,7 +22,7 @@ def run(inpath, outpath): renderer = poppler.PageRenderer() full_page = renderer.render_page(page) - img = Image.frombuffer("RGBA", (full_page.width, full_page.height), full_page.data, 'raw', "RGBA", 0, 1) + img = Image.frombuffer("RGBA", (full_page.width, full_page.height), full_page.data, 'raw', "BGRA", 0, 1) img.thumbnail((180,300), Image.BICUBIC) #img.thumbnail((360,600), Image.BICUBIC) img.save(outpath) -- cgit v1.2.3