How to align images on left side using page.insert_image #2149
-
I am using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
No, not directly. But indirectly, you have ways to achieve what you want: import fitz
import pathlib
stream = pathlib.Path("nur-ruhig.jpg").read_bytes()
from pprint import pprint
pprint(fitz.image_profile(stream))
{'bpc': 8,
'colorspace': 3,
'cs-name': 'DeviceRGB',
'ext': 'jpeg',
'height': 501,
'orientation': 0,
'transform': (1.0, 0.0, 0.0, 1.0, 0.0, 0.0),
'width': 439,
'xres': 96,
'yres': 96} If you want to make sure, that the image is aligned at That will cause the image occupying (original) rect with its top-left corner at |
Beta Was this translation helpful? Give feedback.
No, not directly. But indirectly, you have ways to achieve what you want:
The method always exploits at least one of width or height of your
rect
. As you indicated, you are using memory-based images. This makes it easy to determine the image's width and height, e.g. by usingfitz.image_profile
: