Images Are Cropped when Exporting Presentation Slides to SVG and PNG in Python

When attempting to export slides to SVG or PNG formats, an occasional issue arises where the thumbnail becomes truncated. This results in the image shifting towards the right side of the slide, leaving the left side unoccupied.

PNG export code:

thumbnail_file_name = uuid.uuid4().hex
scale_x = (1.0 / pres.slide_size.size.width) * desiredx
scale_y = (1.0 / pres.slide_size.size.height) * desiredy
with pres.slides[slide_number].get_thumbnail(scale_x, scale_y) as bmp:
    thumbnail_path_png = str(
        "{1}/presentations/thumbnail/{0}.png".format(
            thumbnail_file_name,
            settings.base_path,
        ),
    )
    bmp.save(thumbnail_path_png, draw.imaging.ImageFormat.png)
    return thumbnail_path_png

SVG:

name = uuid.uuid4().hex
file_name = str(
    "{1}/presentations/thumbnail/{0}.svg".format(
        name,
        settings.base_path,
    ),
)

with open(file_name, 'wb') as file:
    # setting svg export params
    svgOptions = slides.export.SVGOptions()
    svgOptions.vectorize_text = True
    svgOptions.jpeg_quality = 100
    svgOptions.pictures_compression = slides.export.PicturesCompression.DPI96
    svgOptions.delete_pictures_cropped_areas = True

    slide.write_as_svg(file, svgOptions)
    return file_name

images.zip (82.3 KB)

@anantutkpd,
Thank you for contacting support.

Please check your results using the latest version of Aspose.Slides for Python if it is possible. If the issue persists, please share the following files end information:

  • PowerPoint presentation file
  • OS version on which the code was executed
  • Aspose.Slides version you used