Szwendacz99 / BookStack-Python-exporter

Customizable script for exporting notes from BookStack through API. Export Pages, Chapters, Books, attachments and images.
MIT License
23 stars 3 forks source link

Exporting Images #7

Closed Krafting closed 3 months ago

Krafting commented 4 months ago

Hello,

Thank you for your work on this script, I'm wondering if it could be possible to also export images as images files. For now I use the PDF options to get a file with the images, but when using markdown the image would not be shown if the bookstack server is down (for exemple when you backup your data and need to have a local copy of the images too if you want to restore it)

Maybe the images could be put in a folder with the name of the Page alongside the .md/.pdf ?

Thank you!

Szwendacz99 commented 4 months ago

This is possible, but can be done in few ways and none of them seem perfect. For example you probably can have 2 images with the same filename in the same document, they just need to be uploaded in different month, as their path look like /uploads/images/gallery/2021-10/nature-image-1200x400-4.jpg. So there would be need to nest those images a little in directories, like 2021-10/nature-image-1200x400-4.jpg. Or names could be replaced with hashes, but that would look bad and harder to browse images. There is also need for updating the markdown contents, which thankfully should be relatively easy, because gallery api provides markdown "content", which is basically the markdown tag, like ![nature_image_1200x400_4.jpg](https://demo.bookstackapp.com/uploads/images/gallery/2021-10/scaled-1680-/nature-image-1200x400-4.jpg).

I might try to do that, not sure when exactly, as it seem not so easy to do it right.

Szwendacz99 commented 3 months ago

I updated script with 3 additionall flags: --images, --markdown-images, and --images-dir. In the end I found out that API does not provide a way to tell what images are currently on a given page, so updating markdown files to point to downloaded images is done in a tricky way, that might have side effects.

If there are any problem with that mechanism, let me know, there might be fix for some possible problems if they occur.