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.
![Screenshot from 2023-12-29 11-17-27](https://private-user-images.githubusercontent.com/69640666/293315586-17184b10-5cf1-435b-a26f-2e4367ec82ec.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYwMzY4NzgsIm5iZiI6MTcyNjAzNjU3OCwicGF0aCI6Ii82OTY0MDY2Ni8yOTMzMTU1ODYtMTcxODRiMTAtNWNmMS00MzViLWEyNmYtMmU0MzY3ZWM4MmVjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTExVDA2MzYxOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTUyM2E0NzMyYzE3Zjk0YzcwODQ1Y2Q0N2FmMjU2ODNjYzJlOWYwNjNiMmQ0MWJiNTQxYzIzODMzZWIwOTk4MjImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.ZdG_bYoCzvNLkYpRqJ7MsA_BGG8hrKepHN5LbWeaFhs)
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