extract image type #514
Replies: 1 comment
-
Hi @NathanTech7713, and very interesting question — thanks for raising it! I don't spend much time working with images in PDFs, so I don't have great answers for this, but it's worth discussing/exploring.
It looks like
It's important, for the rest of def save_image(image, path):
with open(path, "wb") as f:
data = image["stream"].get_data()
f.write(data)
Please see https://github.com/jsvine/pdfplumber/blob/stable/CONTRIBUTING.md If you have questions that are not answered there, please let me know and I can try to answer them. |
Beta Was this translation helpful? Give feedback.
-
Hi there,
I was wondering if there is a way to get the image format from the pdf?
Take the below code for example:
As it stands, you can currently do:
image_data=image["stream"].get_data()
But without knowing the type of that image, I don't see how you could save that to a separate file or display it?
relatedly, I'd love to be able to contribute to this image object as I think making it an object rather than a dictionary would make life so much easier.
For example instead of:
image["stream"].get_data()
simply have:
image.get_data()
I think I have the coding knowledge, but don't understand the contributing requirements that well.
thanks in advance.
Nathan
Beta Was this translation helpful? Give feedback.
All reactions