Skip to content
Discussion options

You must be logged in to vote

In your code you have to actively set the dpi, otherwise it will not be made part of the PNG you are saving:

zoom_x = 1.0
zoom_y = 1.0
trans = fitz.Matrix(zoom_x, zoom_y).prerotate(rotate)
pm = page.get_pixmap(matrix=trans, alpha=False)
pm.set_dpi(x_resolution, y_resolution)  # <=== !!!
pm.save(imgName)

So if I am computing correctly, for a zoom factor of 2 (which corresponds to 2 * 72 = 144 dpi), you should use pm.set_dpi(144, 144).
The coordinates of the bbox should not be changed.

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
5 replies
@trulymust
Comment options

@JorjMcKie
Comment options

@trulymust
Comment options

@JorjMcKie
Comment options

@trulymust
Comment options

Comment options

You must be logged in to vote
1 reply
@trulymust
Comment options

Answer selected by trulymust
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants