Image Output

Image Output

ImageSaveOptions controls the raster format and resolution when calling to_image() on PsDocument or XpsDocument. Pass an ImageSaveOptions instance as the options argument to to_image().


Setting Format and DPI

Create an ImageSaveOptions instance and set format ("png" or "jpeg") and dpi:

from aspose.page.ps.document import PsDocument
from aspose.page.ps.output import ImageSaveOptions
from pathlib import Path

doc = PsDocument.from_file("input.ps")
opts = ImageSaveOptions(format="png", dpi=150)
Path("output.png").write_bytes(doc.to_image(opts))

Supported Output Formats

Formatformat value
PNG"png"
JPEG"jpeg"

Tips and Best Practices

  • Use dpi=150 or higher for document preview thumbnails.
  • Use dpi=96 (the default) for web display or icon generation.
  • PNG is lossless; use JPEG when file size is more important than quality.
  • All to_image() calls return bytes — no temporary files required.

API Reference Summary

Class / PropertyDescription
ImageSaveOptions.formatOutput format: "png" or "jpeg"
ImageSaveOptions.dpiOutput resolution in DPI
ImageSaveOptions.raster_writerOptional custom raster writer
ImageSaveOptions.additional_fonts_folderOptional path to additional fonts

See Also