How to Convert WebP to PDF with Python? Need a Simple Solution! or Best Way to Convert WebP to PDF wi

18 Replies, 1404 Views

Hey! For webp to pdf with python, I’d recommend using `Pillow` (PIL) + `fpdf`.

First, open the webp with PIL, then use fpdf to add it to a PDF. Here’s a quick snippet:

```python
from PIL import Image
from fpdf import FPDF

img = Image.open('image.webp')
img.save('temp.png') # Save as PNG first

pdf = FPDF()
pdf.add_page()
pdf.image('temp.png', 10, 10, 100)
pdf.output("output.pdf")
```

Not the *cleanest*, but it works!

Messages In This Thread



Users browsing this thread: 1 Guest(s)