Код: Выделить всё
import io
import pikepdf
from PIL import Image
with pikepdf.open("./doc.pdf") as pdf:
for page in pdf.pages:
for image_key, image_data in page.images.items():
raw_data_stream = image_data.get_raw_stream_buffer()
img_data_io = io.BytesIO(raw_data_stream)
img_data_io.seek(0)
img = Image.open(img_data_io)
Я пытался изменить его на
Код: Выделить всё
img = Image.open(img_data_io.read())
Это содержимое image_data:
Код: Выделить всё
, data=, {
"/BitsPerComponent": 4,
"/ColorSpace": [ "/Indexed", [ "/ICCBased", pikepdf.Stream(owner=, data=, {
"/Alternate": "/DeviceRGB",
"/Filter": "/FlateDecode",
"/Length": 2598,
"/N": 3
}) ], 15, pikepdf.Stream(owner=, data=, {
"/Length": 49
}) ],
"/Filter": "/FlateDecode",
"/Height": 326,
"/Length": 28607,
"/Subtype": "/Image",
"/Type": "/XObject",
"/Width": 1455
})>
Подробнее здесь: https://stackoverflow.com/questions/791 ... -in-python
Мобильная версия