How to Convert WebP to PDF with Python? Any Efficient Solutions?

20 Replies, 1455 Views

Hey! Just wanted to chime in—I’ve used `PyMuPDF` (aka Fitz) for this. It’s a bit niche but works well for handling PDFs and images.

Here’s a quick example:
```python
import fitz

doc = fitz.open()
img = fitz.Pixmap("image.webp")
doc.insert_page(-1, width=img.width, height=img.height).insert_image(img.irect, pixmap=img)
doc.save("output.pdf")
```

Hope that helps!

Messages In This Thread



Users browsing this thread: 1 Guest(s)