diff --git a/Scripts/pdf-image-extractor.py b/Scripts/pdf-image-extractor.py index 601309c29..c1ac03238 100644 --- a/Scripts/pdf-image-extractor.py +++ b/Scripts/pdf-image-extractor.py @@ -34,6 +34,9 @@ if '/Filter' in xObject[obj]: if xObject[obj]['/Filter'] == '/FlateDecode': img = Image.frombytes(mode, size, data) + if "/SMask" in xObject[obj]: # add alpha channel + alpha = Image.frombytes("L", size, xObject[obj]["/SMask"].getData()) + img.putalpha(alpha) img.save(obj[1:] + ".png") elif xObject[obj]['/Filter'] == '/DCTDecode': img = open(obj[1:] + ".jpg", "wb")