Document.extract_image seems to extract image png mirrored in some cases #1217
Answered
by
JorjMcKie
p1-dta
asked this question in
Looking for help
Replies: 3 comments 15 replies
-
Guilty is the PDF creator, who decided to do this! import fitz
msg = ""
m = fitz.Matrix()
if m.b * m.c == 0: # means rotation by 0, 180, or flippings
if m.a * m.d > 0: # same sign -> no flippings
if m.a < 0: # so both, a and d are negative!
msg = "rot 180"
else:
msg = "nothing"
else: # we have a flip
if m.a < 0: # horizontal flip
msg = "left-right"
else:
msg = "up-down"
elif abs(m.b) == abs(m.c):
if m.b * m.c < 0:
if m.b > 0:
msg = "rot 90"
else:
msg = "rot 270"
else:
if m.b > 0:
msg = "up-down, rot 90"
else:
msg = "rot 90, updown"
else:
error = True
if error:
print("unsupported matrix")
else:
print(msg) |
Beta Was this translation helpful? Give feedback.
2 replies
-
What do the EXIF data of the images say? |
Beta Was this translation helpful? Give feedback.
10 replies
-
Yes please do so.
Yesterday I found an error in computing the transformation matrix via `get_image_bbox()`. This may affect you. You can try `get_image_rects()` instead. This is always correct. It returns a list of tuples `(rect, matrix)`. One tuple for each occurrence of the same image on the page. You probably will find the correct answer with this alternative.
Von meinem iPhone gesendet
Am 6/9/21 um 05:08 schrieb Dorian Turba ***@***.***>:
@JorjMcKie<https://github.com/JorjMcKie> I have an update. I can share the file with you. Do you want me to send it to you on your mailbox ?
|
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
p1-dta
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I have a pdf with only a png in it, but when I get try to extract this png, it's mirrored.
Document.extract_image return a dictionary with, for the value "image", the image but mirrored.
This happen only for one file, works fine for many more.
I have no clues, neither do my colleagues.
I don't know how to prevent it or how to detect a mirror to mirror it again.
Beta Was this translation helpful? Give feedback.
All reactions