python_ooo_dev_tools
python_ooo_dev_tools copied to clipboard
ShapePng export error width&height
Hi! I'm trying to create a script to export each shape of each slide as a png image, but I found that each exported shape is a square instead of the original shape. I noticed that the _get_dpi_width_height function had two variables with the same name, pixel_width, to receive the return value, and ExportPng also set width and height to pixel_width
my code
imp = ImpressDoc.open_doc(fnm=path, loader=self.__loader)
slide_count = imp.get_slides_count()
logger.info(f"Slides count: {slide_count}")
slides = imp.get_slides()
for slide in slides:
shapes = slide.get_shapes()
for shape in shapes:
logger.info("shape type:"+shape.get_shape_type())
logger.info(f"shape size: {shape.size.width.value}*{shape.size.height.value}")
shape.export_shape_png(fnm="./output/"+str(uuid4())+".png",resolution=300)
export_shape_png
class ShapePng(ShapeExportPngBase):
def __init__(self, shape: Any, lo_inst: LoInst | None = None):
ShapeExportPngBase.__init__(self, lo_inst=lo_inst)
self._component = mLo.Lo.qi(XComponent, shape, True)
self._filter_name = "draw_png_Export"
def export(self, fnm: PathOrStr, resolution: int = 96) -> None:
...
sz = shape.getSize()
pixel_width, pixel_width = self._get_dpi_width_height(sz.Width, sz.Height, resolution)
event_data = ExportPng(
pixel_width=pixel_width,
pixel_height=pixel_width,
compression=6,
interlaced=False,
translucent=True,
logical_width=pixel_width,
logical_height=pixel_width,
)
Is this designed like this? Or is it a bug?