How transform the extract images? #1896
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
When the image is displayed in a bbox on a page, it must always be transformed. rects = page.get_image_rects(xref, transform=True)
# normally is a list with 1 item (multiple items if same image is displayed multiple times on the page)
rect, matrix = rects[0] The transformation matrix fullfills the following equation - see docu details here: imgrect = fitz.Rect(0, 0, width, height) # the original rectangle of the image
shrink = fitz.Matrix(1/width, 0, 0, 1/height, 0, 0) # matrix converting image rect to unit rect
bbox = imgrect * shrink * transform # this is how bbox on page is computed So |
Beta Was this translation helpful? Give feedback.
-
You can inspect the transformation matrix properties and compute the respective inverted matrix. Depending on the return code of the function |
Beta Was this translation helpful? Give feedback.
You can inspect the transformation matrix properties and compute the respective inverted matrix.
Then load the image in a pixmap and transform it with that matrix.
matrix_property.zip
Depending on the return code of the function
matprop
build that inverted matrix. So if e.g. the return code is(3, "rot 90")
take~fitz.Matrix(90)
.