Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thumbnail creation taking too long #471

Open
anirudhagarwal1 opened this issue May 13, 2024 · 2 comments
Open

Thumbnail creation taking too long #471

anirudhagarwal1 opened this issue May 13, 2024 · 2 comments

Comments

@anirudhagarwal1
Copy link

I want to convert pdf to png and somehow for a few PDF files, the conversion process takes a very long time. The page size is A4 only.

I am attaching a sample PDF file.
temp-6.pdf

# Extract each page as an image
image = pyvips.Image.new_from_file(pdf_file, dpi=300, page=i)

# Save the image
image.pngsave(f"page_{i+1}.{format}")

The pngsave function takes about 50 seconds on my Macbook Pro. I have tried to save jpeg as well, which takes almost the same time.

What could be the issue? Any inputs would be highly appreciated.

@jcupitt
Copy link
Member

jcupitt commented May 13, 2024

Hi @anirudhagarwal1,

Wow, that is slow. I tried your file on my PC:

$ time vips copy very-slow.pdf[dpi=300] x.jpg 

real	0m39.694s
user	0m37.869s
sys	0m1.938s

And it's almost as bad.

I tried firefox preview and it's also very slow.

By default, libvips uses poppler for PDF rendering and I think your file probably just uses some feature with a slow implementation in poppler. libvips can also use PDFium as a PDF backend, perhaps that's quicker? I'll try it.

@jcupitt
Copy link
Member

jcupitt commented May 13, 2024

I recompiled my libvips against PDFium 5947 and I now see:

$ time vips copy very-slow.pdf[dpi=300] x.jpg 

real	0m2.216s
user	0m1.324s
sys	0m1.014s

So I think I'd look into installing pdfium on your macbook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants