Feature Request: Native support for standalone images (PNG, JPG, etc.) via MuPDF
Is your feature request related to a problem? Currently, Bookokrat cannot open standalone image files. However, it is highly useful to leverage Bookokrat's high-performance terminal rendering and file-watching capabilities as a live-viewer for diagramming tools (like PlantUML) or other workflows that output to flat image formats.
Describe the solution you'd like Since the mupdf backend already natively supports rendering single-page image formats out of the box, we can add these extensions to the detect_format and discover_book_in_dir functions.
I have tested this locally, and MuPDF handles terminal image rendering flawlessly without any new rendering logic required.
Architectural Discussion I would like to submit a PR for this, but I wanted to check if this aligns with the project's goals first, and if so, how you would prefer it modeled internally:
- Approach A (Minimal Code): Route the image extensions directly to the existing PDF pipeline since MuPDF handles both exactly the same way internally.
"pdf" | "png" | "jpg" | "jpeg" | "gif" | "bmp | "tif" | "tiff" => Some(BookFormat::Pdf),
- Approach B (Semantic Cleanliness): Create a new BookFormat::Image variant. This would be semantically cleaner but would require adding match arms across the codebase wherever BookFormat::Pdf currently hands off to the MuPDF worker.
Hey. I'm a bit perplexed on this one. Bookokrat is essentially an app for reading books. I think that standalone image viewer is 1-2k lines of code. And not much would be used out of bookokrat code & architecture.
Yes, probably out of scope for the project. But i started using the live loading feature with writing latex (live loading the updated pdf). Now i also needed a tool to live load images (png) to view diagrams generated with plantuml. I have just added this two lines (Approach A), so images get loaded in the same pipeline as PDF, processed through MuPDF, which also supports png.
@HoseaD interesting. Do you mind sharing your workflow around latex ?
I use Neovim and Ghostty. My setup consists of:
- Neovim + LSP + VimTeX: Handles editing and continuous compilation via latexmk every time I save.
- Ghostty: I use a window split to keep my code and PDF side-by-side.
- Bookokrat: Acts as the viewer in the adjacent split with its live-reloading feature.
Forward and Backward search would be nice, but i'm not missing it to much.
Same use case for me. I had asked for the same on reddit i.e. synctex support.
@krishnakumarg1984 i have experimental branch with synctex support, never managed to get it to a reasonably working state. I'll try to revive that work. Are you also interested in standalone images support?
I am interested in using bookokrat for live previews of pdfs generated by latex and typst runs. Will have a vertical split pane to preview. Not so sure an epub/pdf reader should also be a standalone image viewer when other tools are available for this purpose.
@krishnakumarg1984 hi! synctex support has landed in main. I'm not a big user of latex so my testing was not super comprehensive. but if you're still using the app, let me know if you'll see any issues:
I've tested it in with neovim vimtex.
The setup details are in settings window (space+s)
Thank you so much. Let me check it out.
In the meantime, perhaps you might wish to @ mention this to bring this to the attention of lervag (that is their GitHub handle), who is the maintainer of vimtex, the most comprehensive latex plugin for vim & neovim. Lervag can perhaps do further testing and may perhaps wish to provide a viewer backend with bookokrat.