Convert webp image to pdf
Contents
[
Hide
]
Using Aspose.Imaging we can convert single paged or animated webp image to pdf.
The following code snippet shows you how to convert webp to pdf.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import aspose.pycore as aspycore | |
from aspose.imaging import Image | |
from aspose.imaging.fileformats.webp import WebPImage | |
from aspose.imaging.imageoptions import PdfOptions | |
import os | |
if 'TEMPLATE_DIR' in os.environ: | |
templates_folder = os.environ['TEMPLATE_DIR'] | |
else: | |
templates_folder = r"C:\Users\USER\Downloads\templates" | |
delete_output = 'SAVE_OUTPUT' not in os.environ | |
data_dir = templates_folder | |
with aspycore.as_of(Image.load(os.path.join(data_dir, "template.webp")), WebPImage) as image: | |
image.save(os.path.join(data_dir, "result.pdf"), PdfOptions()) | |
if delete_output: | |
os.remove(os.path.join(data_dir, "result.pdf")) |