Help me, about matrices。 #1932
-
Given the value of the matrix, how can I use it correctly when inserting an image? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Image insertion currently only supports rotation angles of 0, 90, 180, 270 degrees. Not as you indicated in your image.
Using a matrix in this process is never required and thus not supported either. imgdoc = fitz.open(<image file>)
srcbytes = imgdoc.convert_to_pdf()
src = fitz.open("pdf", srcbytes)
# 'page' is your target page:
page.show_pdf_page(rect, # rect on the page, center of image and the rect will be equal
src, # temp image PDF
0, # its first (and only) page number
rotate=angle, # desired rotation angle - any float value
) |
Beta Was this translation helpful? Give feedback.
-
The matrix without its translation part matrix.e, matrix.f should be the product of a scale matrix fitz.Matrix(a, d) * fitz.Matrix(alpha) = fitz.Matrix(37, 58, 46, -29, 0, 0) to determine a, d, and alpha. |
Beta Was this translation helpful? Give feedback.
The matrix without its translation part matrix.e, matrix.f should be the product of a scale matrix
fitz.Matrix(a, d)
and a rotation matrixfitz.Matrix(alpha)
.I currently have no good advice other than solving the set of 4 equations behind
to determine a, d, and alpha.
A rotation matrix is defined as
fitz.Matrix(cos, sin, −sin, cos, 0, 0)
. A scale matrix has the componentsfitz.Matrix(a, 0, 0, d, 0, 0)
. So you have 4 variables and 4 equations. Once you have the values for cos and sin you can compute alpha via the arcus functions.