-
Hello, developer, I want to ask about the relationship between the bbox and the DPI of the picture. For example, I generated the bbox in the default size of PDF, but the resolution was increased by 2 times when exporting the picture. How should I change the bbox? Or how should I generate the bbox in the resolution I want to export at the beginning? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
You seem to talk about images created by pixmap generations. There is no relationship between the two things. You have to actively set the dpi if another than the default is needed. |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
BTW you are aware that you do not need to save the pixmap as an image if all you want to do is using i directly afterwards? |
Beta Was this translation helpful? Give feedback.
In your code you have to actively set the dpi, otherwise it will not be made part of the PNG you are saving:
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.