Convert webp image to pdf

Contents
[ ]

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.

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"))