Skip to content
Discussion options

You must be logged in to vote

I am using page.insert_image(rect, stream=stre, xref=0,rotate=page.rotation) for inserting images. When I place the images, the images are center aligned. is there a way to specify the image alignment?

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 using fitz.image_profile:

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'

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by MallRoy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants