dmarcuse / fvtt-adventure-bundler

Export and import Foundry adventures, assets included!
MIT License
3 stars 2 forks source link

Journal notes export not images #5

Open Miccolo02 opened 1 year ago

Miccolo02 commented 1 year ago

I find it a pity that the images in the notes are not exported along. Is this a bug? If not, it would be a good feature.

dmarcuse commented 1 year ago

Could you share more details about the use case? If you're using standard journal entries with image pages, those should work fine - if you're embedding images in a text page, I haven't implemented support for that yet because it's likely to be somewhat error-prone.

Miccolo02 commented 1 year ago

At least I'm glad it's not a bug. I have several adventures where I use images as handouts directly at the location of use so that I can access them directly. For example, a trap and an image of my players falling into it.

Why is this difficult? The exported JSON file contains information about which image is used, so couldn't you include the image in the assets and automatically adjust the path?

dmarcuse commented 1 year ago

Sounds like you have images in text pages then? The difficulty in this case is that text pages are raw HTML: In order to support images, I would need to parse the HTML and extract images - which could be included as image tags, frames, CSS, or so on. It's not something I'm opposed to supporting on a best-effort basis, but if I do add support it will be pretty limited and will still fail in some cases. With image pages in journal entries, it's comparatively simple - there's just a single value which is known to be a path or URL to an image.

Miccolo02 commented 1 year ago

Yes, the images are integrated into a text page.

Okay, I was actually only thinking about the img tags, since that's the standard way to do it when you're using the standard editor. I didn't even consider the possibility of integrating it differently through the HTML source code, you're right about that. For now, I would just use the img tag. But of course, you're right that it needs to be parsed, at least to a limited extent. Parsing the img tag should still be relatively easy to do.

For me, that would be rudimentary enough and it's also possible to expand on it further.

theksi commented 10 months ago

Hello, I encountered this case yesterday and didn't though first to check here for investigations. Usually the sole journal with an embedded image is the "Where On Golarion" (ou "Where in the universe page") What is a bit strange is that I checked a few of my adventure bundle and found one case where the image was exported and imported and while comparing the only difference I found was the image format .webp would not be exported .jpeg was exported.

I am now puzzled When I reading in the above description of this issue that you haven't yet implemented anything. I'll work tonight on reproducing this and keeping you up to date. On top of that I have implemented a compendium parser that would pack all assets of a compendium, this included embedded pages. It is based on python and can share it with you for the logic; the HTML part was the pretty easy part as it is game system-independant. (My dev on this is stopped since foundry 11 changed the compendium format and I am using your module) . As long as you won't mock my bad coding, you can have a look at this https://github.com/theksi/foundry-pack-modules/blob/pack-adventure-compendium/compendiumlib/compendiumlib.py#L76 ; I'm using beautifull soup to parse HTML and get all <img ...> tags

dmarcuse commented 10 months ago

@theksi I'm assuming you used pdftofoundry or Deidril's import module in that case, right? Could you let me know what scenario you were trying to import so I can try and reproduce the issue?

Extracting the <img> tags isn't the hard part, unfortunately. The difficult part is updating the module to correctly updating the image file paths within journal text when those images are uploaded on import. Right now, the module only supports replacing entire strings - e.g. the src field within a Foundry Token document for the token art. Replacing substrings within a full HTML journal page is much more complicated, especially when it comes to correctly handling cases with multiple images in a single HTML journal page that need to be updated. I have a rough plan for how to implement this, but I've been busy between work, major Pathfinder conventions, and other miscellaneous stuff that I haven't had the time to actually implement it yet.

theksi commented 10 months ago

Hello, @dmarcuse To start with when it comes to PF2e, I'm using either pdftofoundry or Deidrils, then I re-arrange the journals and add illustrations. I've found some image were imported and others weren't. Actually they were not imported as you will see in this screenshot,

So you were totally right, the content in HTML was left untouched and some pictures were displayed because there were found under my server's directory tree.

I wish I could help you in this as I am relying on AdventureBundler to pack my preparations to be able to use them on any other foundry server. Unfortunately, I am extremely uncomfortable with the language used to create modules.

theksi commented 10 months ago

PS : this is the same issue for my starfinder preparations that I fiexed by synchronizing data between my computer and my foundry servers

dmarcuse commented 10 months ago

Thank you! I understand that this is an important issue and I have it in my queue to fix, but I can't make any promises about when it will be done.