Images extracted are mirrored on x-axis. #1074
yashpundir
started this conversation in
Ask for help with specific PDFs
Replies: 2 comments 2 replies
-
When I display your post (in Chrome) and compare with page6 in the PDF (in Acrobat) the images are both in the same orientation. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi @yashpundir, a couple of notes to help you on your
So you could do this: import pdfplumber
pdf = pdfplumber.open("path/to/file.pdf")
page = pdf.pages[5]
im = page.to_image()
im.draw_rects(page.images) ... which returns this: |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I'm new to PDFplumber and I'm trying to draw the images detected by the library on the page itself. I do this using the Page.draw_rects() method and use the x0,y0,x1,y1 coordinates obtained from the Page.images properties. But the rects being plotted are mirrored on the x-axis. Am I providing the coordinates in a different order than what is expected by the draw_rects method?
Here is my code:
rotomecPDF = pdfplumber.open(rotomec)
# load pdfroto_page6 = rotomecPDF.pages[5]
# select page 6pg6_imgs = roto_page6.images
# find images on pg6roto_page6.to_image().draw_rects([(i['x0'],i['y0'],i['x1'],i['y1']) for i in pg6_imgs])
# draw a rect for each imgHere is the pdf
Rotomec_5002.pdf
And here is the output of the above code. As you can see the images are inverted on the x-axis.
How can I fix this. I know I can write a function to invert the points on the coordinate plane. But I think I'm doing something wrong as the chances of this being a bug in the library are really low.
Thank you in advance and apologies for my English.
Beta Was this translation helpful? Give feedback.
All reactions