pdf-to-png-converter icon indicating copy to clipboard operation
pdf-to-png-converter copied to clipboard

File reading/writing optimization to async

Open Zirafnik opened this issue 1 year ago • 1 comments

I have noticed, while quickly going through the codebase, that this library uses existsSync, mkdirSync, readFileSync and writeFileSync inside otherwise already async functions. Is there a reason for that?

This blocks the execution, instead of allowing Node to process along further, while the OS (filesystem) is writing/reading files.

Should we not update the code to at least use async versions from fs/promises? Optimally, I believe streams should be used, like createReadStream and createWriteStream, to minimize the impact on memory.

After a week of testing pretty much all the pdf-to-img libraries out there, this is the only one that works properly, and gives me good quality images. The only problem I now have is that it is slow.

PDF2Pic, has a nice code utilizing streams, which is extremely fast and efficient, but the owner no longer updates the library, and there are quite a few broken things, such as density, which controls the output quality. I am mentioning it here only as a potential source of inspiration.

Zirafnik avatar Apr 20 '23 19:04 Zirafnik