I wrote a script to do this a long time ago. It is essentially glue code around a few utilities that do the heavy lifting. The difference between my script and the other tools at the time is that mine was the only one that did all of the following:
- had a similar compression ratio to the original DjVu file (1.5-2x the size instead of 10-20x the size)
- preserved bookmarks / table of contents metadata (for navigation in the pdf reader)
- preserved the embedded text layer for searching
That being said, it is very primitive. I just made sure it worked well for all of my own files and haven't worked on it since.