Hình ảnh Output

Hình ảnh Output

ImageSaveOptions kiểm soát định dạng và độ phân giải raster khi gọi điện thoại to_image() trên PsDocument hoặc XpsDocument.Pass một ImageSaveOptions Ví dụ như The options Argument cho to_image().


Thiết lập định dạng và DPI

tạo một ImageSaveOptions Lời bài hát: Instance And Set format ("png" hoặc "jpeg") và 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))

Các Định dạng Đầu ra Được Hỗ trợ

Formatformat Giá trị
PNG"png"
JPEG"jpeg"

Mẹo và Thực hành Tốt nhất

  • Sử dụng dpi=150 hoặc cao hơn cho các tài liệu Preview nhãn hiệu.
  • Sử dụng dpi=96 (the mặc định) cho web display hoặc icon generation.
  • PNG là không mất; sử dụng JPEG khi kích thước tệp quan trọng hơn chất lượng.
  • Tất cả to_image() Lời gọi trở lại bytes - Không có tệp tạm thời được yêu cầu.

Tóm tắt Tham chiếu API

Class / Tài sảnDescription
ImageSaveOptions.formatĐịnh dạng xuất khẩu: "png" hoặc "jpeg"
ImageSaveOptions.dpiGiải pháp phát hành trong DPI
ImageSaveOptions.raster_writerTùy chọn tùy chỉnh raster writer
ImageSaveOptions.additional_fonts_folderCách chọn lựa để thêm fonts

See Also

 Tiếng Việt